# Agentic Localization, Low to no cost for tokens.

> Source: <https://dev.to/harmanpreetsingh/agentic-localization-low-to-no-cost-for-tokens-4636>
> Published: 2026-08-31 18:30:24+00:00

Hackathon Submission Disclosure:

I created this piece of content for the purposes of entering the Google Cloud Agentic Hackathon. It details the architecture, real-world benchmarks, and cloud infrastructure behind **langPeanut.

If you have ever tried using an LLM to localize an existing app, you probably noticed the same frustrating pattern: you feed a prompt 500 lines of React, Flutter, or Swift code, ask it to extract strings and replace them with localization hooks, and get back code that looks convincing at first glance—until you run the compiler.

Quotes get escaped incorrectly, JSX children trees get mangled, ICU plural syntax breaks, and comments silently vanish.

When we set out to build **langPeanut**, our goal wasn’t to build another "AI code generator." It was to solve localization as an **AST boundary problem, not a text generation problem**.

Here is how we built a multi-agent localization and SEO platform in Go, powered by **Gemini 3.7 Flash**, and deployed reliably to **Google Cloud Compute Engine (GCE)** with **Google Cloud Pub/Sub**.

The fundamental flaw with single-prompt LLM refactoring is giving the model write-access to the entire file structure.

In `langPeanut`

, the LLM is **never allowed to rewrite a full source file**. Instead, we split the workflow into strict deterministic boundaries and narrow AI judgment:

```
[ Deterministic Tree-Sitter AST ] ──► Extracts string literals & byte-offsets
               │
               ▼
[ Gemini 3.7 Flash Judgment ]    ──► Disambiguates context & translates (ICU-safe)
               │
               ▼
[ Deterministic Patch Engine ]   ──► Slices & splices exact byte ranges
               │
               ▼
[ 4-Tier Critic & Compiler ]     ──► Syntax, key-parity, & AST validation
```

`google.golang.org/genai`

) only for linguistic judgment:
`"Close"`

a button verb or an adjective?`{count, plural, one {# item} other {# items}}`

) remain syntactically identical across locales.`t('key')`

or `AppLocalizations.of(context)`

). Whitespace, comments, and un-targeted code remain 100% untouched.On our 10-case adversarial benchmark (nested JSX expressions, Dart string interpolation, SwiftUI view modifiers), this approach achieved a **100% AST compilation pass rate with 0% formatting drift**.

Rather than a single monolithic script, `langPeanut`

coordinates three specialized systems that share a single on-disk project state:

`langPeanut chat`

):`langPeanut seo`

):Locally, `langPeanut`

runs as a zero-dependency CLI, TUI (Bubble Tea), or a zero-build Web Studio. But for team workflows, we built **langPeanut Cloud**—a hosted GitHub App that monitors repositories, extracts strings on push, and automatically opens clean Pull Requests.

Running an automated agentic bot against arbitrary user repositories introduces two major infrastructure challenges: **webhook reliability** and **execution sandboxing**.

GitHub delivers push webhooks with a very short timeout and minimal retry persistence. If a cloud server restarts during a deployment, hits a database lock, or receives a sudden burst of commits across multiple repositories, incoming webhooks can get dropped silently.

To guarantee zero dropped events, we placed **Google Cloud Pub/Sub** between our webhook ingestion gateway and our worker queue:

```
[ GitHub Push Webhook ]
        │ (verified HMAC signature)
        ▼
[ Ingestion API Handler ]
        │
        ▼
[ Google Cloud Pub/Sub Topic ]
        │
        ▼
[ Subscription Pull Worker ] ──► Acks only after job is safely persisted in SQLite
        │
        ▼
[ Ephemeral Sandboxed Docker Runner ] ──► AST patch → Gemini translation → Opens PR
```

`langpeanut-webhooks`

).We host the stack on an **e2-medium Google Cloud Compute Engine instance** running Ubuntu 24.04 LTS.

To keep the host clean and secure:

For judges and developers wanting to test this live without cloning or configuring infrastructure:
