Back/Engineering/Cursor
AdvancedEngineering

How to Build a Custom AI Translation Service to Replace Expensive SaaS Tools

Build a version controlled localization service that extracts changed source strings, translates them with a language specific glossary and style prompt, validates placeholders and structure, and routes uncertain copy to native language review.

How to Build a Custom AI Translation Service to Replace Expensive SaaS Tools

Luke replaces a costly localization platform with a small service built in Cursor: a GitHub Action extracts changed translation strings, sends them to an LLM using a language specific prompt and glossary, commits the translations, and exposes the same workflow through a CMS button.

Before you start

What you need

  • A source locale, supported target locales, and ownership for each
  • Versioned source strings with stable keys and structured context
  • Approved terminology, do not translate terms, tone guidance, and strong examples per locale
  • CI access to an approved model through scoped secrets
  • Validators for placeholders, markup, keys, length, locale format, and completeness

What you’ll make

A pull request or CMS revision containing structurally valid translations, provenance and confidence, automated validation results, and a focused review queue for nuanced or high impact copy.

Tools used

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

5 steps

Step01

Use an AI Code Editor to Build the Core Logic

Use Cursor to build a small translator that accepts stable keys, source text, context, locale, glossary, and protected tokens, then returns structured output with confidence and notes. Start with test fixtures rather than the full site.

Example prompt
Implement a localization function for [file format]. Input: key, source locale, target locale, source text, product context, glossary, do not translate terms, and protected placeholders or markup. Return valid structured output with translation, confidence, and review reason. Preserve every key and token exactly and add tests for plurals, interpolation, HTML, ICU syntax, empty values, and length constraints.
Step02

Set Up a GitHub Action Trigger

Trigger the service only when source strings or locale instructions change. In CI, extract the affected keys, run translation and validators, and open a reviewable pull request instead of pushing directly to the release branch.

Step03

Create Contextual Prompts for Each Language

Create one versioned prompt per locale with tone, formality, terminology, regional conventions, good examples, rejected examples, and instructions for ambiguous source copy.

Example prompt
Translate from [source locale] to [target locale] for [audience and surface]. Follow this glossary and style guide: [guide]. Preserve protected tokens exactly. If context is insufficient, return NEEDS_CONTEXT with a question rather than guessing. Output only the required schema.
Step04

Translate via LLM and Commit Back

Validate structure, placeholders, terminology, locale formatting, and completeness before committing. Store model, prompt, glossary, source hash, and validation results so reviewers can understand why a string changed.

Step05

Integrate with a CMS (Optional)

Expose the same service in the CMS for authorized editors. Translate a draft field, show source and target side by side, preserve revision history, and require the editor to save the reviewed result rather than silently replacing published copy.

What good looks like

  • Every source key has exactly one target value and all placeholders, markup, escapes, and variables survive unchanged.
  • Product names, terminology, tone, dates, numbers, currency, plural rules, and formality follow the locale guide.
  • Only changed or invalidated strings are regenerated, and a rerun produces no unrelated churn.
  • Native reviewers inspect low confidence, legal, safety, pricing, and culturally sensitive content before release.

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

The model changes a placeholder, key, tag, or escape sequence
Protect structural tokens before translation, restore them deterministically, and reject output that fails parsing or placeholder equality.
A grammatically correct translation sounds unnatural or violates local brand conventions
Add native examples and a locale glossary, collect reviewer corrections, and turn recurring feedback into tests and prompt changes.
Every CI run rewrites unchanged strings or oscillates between variants
Hash source plus prompt and glossary versions, translate only invalidated keys, and use deterministic settings where available.
Repository content or credentials are exposed through logs or model requests
Send only required strings and context, use scoped secrets, redact logs, and keep restricted content in an approved environment.

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready