Adam BlansettSenior Full-Stack & AI Engineer
AI Engineering
11 min read
Adam Blansett

Building a Self-Hosted AI Localization Manager: 7-Format Round-Trip Sync, pgvector Translation Memory, and RTL BiDi CI Gates

Inside ai-localization-manager: round-trip JSON/PO/ARB/XLIFF/Android/iOS sync, pgvector HNSW translation memory, deterministic ICU/placeholder/RTL BiDi/register QA, GitHub PR sync, and the l10n-gate CI CLI.

i18nTranslation MemorypgvectorRTL BiDiICU PluralsGitHub ActionsFastAPI

Multilingual web and mobile teams routinely discover broken ICU plural strings, corrupted `{username}` interpolation variables, clipped RTL layouts, or untranslated keys only after a release ships. Translating raw files through generic AI prompts without deterministic format guards makes those regressions worse.

AI Content Localization & Translation Manager (GitHub repository) brings round-trip i18n engineering, `pgvector` semantic translation memory, deterministic cultural/structural QA, and GitHub PR + CI release gating into one self-hosted FastAPI, PostgreSQL, Celery/Redis, and React 18 workbench.

7-Format Round-Trip Catalog Sync & pgvector Translation Memory#

Under `catalogs/`, multipart uploads (`POST /catalogs/upload`) and round-trip serializers support **JSON**, **GNU gettext PO**, **Flutter ARB**, **Markdown**, **XLIFF 2.0/1.2**, **Android `strings.xml`**, and **iOS `.strings`** while tracking SHA-256 source hashes to pinpoint stale translations immediately. In `tm_glossary/`, Alembic-migrated PostgreSQL `pgvector` HNSW indexes (`vector_cosine_ops` `<=>`, with SQLite dev fallback) blend semantic cosine similarity with lexical fuzzy search, auto-harvest linguist-approved strings into TM, and enforce strict Do-Not-Translate (DNT) and forbidden-variant termbases.

Deterministic Placeholder, ICU, RTL BiDi & Formality Register QA#

Before any string enters the linguist approval queue, `qa_checks/` executes deterministic verification across `{var}`, `{{var}}`, `%(name)s`, `%1$s`, `${var}`, and ICU `{count, plural, ...}` tokens, HTML/Markdown tag balance, `maxLength` expansion budgets, RTL BiDi isolation (`\u2068...\u2069`), formality registers (`es`, `de`, `fr`, `ja`), US date/currency drift, and French double-punctuation spacing.

Reversible-PII LLM Routing, GitHub PR Sync & `l10n-gate` CI CLI#

The `llm/` router resolves `tm_exact` hits first before calling offline `mock`, local Ollama, or Gemini with reversible PII scrubbing that leaves i18n placeholders intact. Background Celery + Redis workers stream progress via SSE (`/jobs/events`), while GitHub integrations pull source files (`/git/pull`), open translation PRs (`/git/export-pr`), and block incomplete releases in CI:

l10n_gate_ci.sh
# Fail CI if target locales have missing keys, stale hashes, or QA errors
l10n-gate check --api-url http://localhost:8000 --project-id "$PROJECT_ID" --token "$L10N_TOKEN"
  • Workbench & Verification (`frontend/`): React 18 TypeScript workbench with `AuthGate`, RTL editor, TM/Glossary manager, QA/Nuance analyzer, and Git PR preview verified by Vitest, `npm audit`, and Chromium Playwright E2E.
  • Enterprise Baseline (`core/`): HS256 JWT + PBKDF2-SHA256 RBAC (`admin`, `localization_engineer`, `linguist`, `viewer`), memory/Redis ZSET rate limiting, OpenTelemetry FastAPI instrumentation, and Prometheus `/api/v1/metrics`.
Flutter & Web Parity: Native support for Flutter `.arb`, Android `strings.xml`, iOS `.strings`, and web JSON/PO keeps cross-platform mobile and web release trains synchronized from one TM and glossary.

Scaling multilingual web or Flutter products? Explore my AI Engineering and Mobile Engineering capabilities or schedule a consultation.

Applied Architecture

Production Case Studies & Capabilities

Explore how these engineering patterns are deployed in production systems and available through client engagements.

Case Study

AI Content Localization & Translation Manager

An open-source Python 3.12 (FastAPI), PostgreSQL/pgvector, and React 18 localization platform supporting 7 catalog formats, HNSW cosine translation memory, deterministic ICU/placeholder/RTL/register QA, reversible-PII LLM routing, Celery + SSE background jobs, GitHub PR export, and the `l10n-gate` CLI.

Read Case Study
Related Engineering Service

AI Engineering & LLM Integration

Many AI initiatives fail in production due to prompt fragility, high token latency, hallucination risks, and lack of structured evaluation. I bridge the gap between experimental LLM prompts and deterministic software engineering.

Related Engineering Service

Software Architecture & System Design

Fast-moving teams frequently accrue hidden architectural liabilities: tangled domain logic, unmaintainable monoliths, or over-engineered microservices that paralyze development.

Frequently Asked Questions

Which localization file formats does ai-localization-manager support round-trip?
The catalogs module supports round-trip parsing, serialization, and multipart uploads across nested JSON, GNU gettext PO, Flutter ARB, Markdown, XLIFF 2.0/1.2, Android strings.xml, and iOS .strings with SHA-256 key-diff and stale-translation detection.
How does the QA engine prevent broken placeholders and RTL layout regressions?
Deterministic checks in qa_checks/ validate {var}, {{var}}, %(name)s, %1$s, ${var}, and ICU plural syntax, HTML/Markdown balance, maxLength expansion budgets, RTL Unicode BiDi isolation (\u2068...\u2069), formality registers (es, de, fr, ja), and French punctuation rules.
How can CI/CD pipelines block deploys with missing or unapproved translation keys?
Teams can run the standalone l10n-gate CLI or the composite GitHub Action (.github/actions/l10n-gate/action.yml) against the API to fail PRs whenever required locale keys are missing, stale, or failing QA checks.
Share this technical guide

Need Help Solving This in Your Application?

I partner with founders, executives, and engineering leaders to design architectures, resolve production bottlenecks, and deliver resilient software.

Related Technical Articles