59API

← Volver a las guías

AI Software Localization: Translate JSON Without Broken UI

Guías · EN · 2026-09-18

Build a Safe AI Translation Pipeline for Software

AI can translate product interfaces far faster than a manual copy-and-paste workflow, but software localization is not simply translating sentences. A bad translation can break ICU plural rules, replace a variable such as {name}, alter a URL, or make a button too long for the interface. The reliable approach is to send structured source strings to an AI model, give it explicit localization rules, and validate the response before it reaches your repository.

This example translates a small English JSON catalog into French for France. The same pattern works for React, mobile applications, SaaS dashboards, email templates, and documentation portals.

Prepare Strings and Rules Before Calling the Model

Keep each user-facing string behind a stable key. Do not send database fields, secrets, user-generated content, or internal error details to a translation model. Include context when a label is ambiguous: “Save” can mean storing a document or saving money, and “Plan” may mean a subscription tier.

Create a glossary for product language that must remain consistent. For example, a product might translate “workspace” as “espace de travail” everywhere, while the brand name “59API” must never be translated. Also decide which tokens are protected: variables, ICU syntax, HTML entities, URLs, code identifiers, and trademarked product names.

Here is a compact source catalog:

source = {
"account.greeting": "Welcome back, {name}!",
"files.count": "{count, plural, one {# file uploaded} other {# files uploaded}}",
"billing.cta": "Manage plan"
}

In production, store approved translations as translation memory. Before requesting a new translation, look up an exact source-string match for the target locale. This lowers costs and prevents previously approved wording from changing unexpectedly.

Call an OpenAI-Compatible Model Through 59API

59API is useful for localization jobs because it provides pay-as-you-go access to native official-quality Claude and GPT models through an OpenAI-compatible API. You can use a fast, economical model such as Claude Haiku for routine catalog updates, then send high-visibility onboarding, legal-adjacent, or marketing strings to a stronger model such as Sonnet or Opus for review. This avoids paying premium-model rates for every comma change.

Install the OpenAI Python SDK, set your API key and chosen model ID as environment variables, then use the 59API endpoint:

from openai import OpenAI
import json
import os

client = OpenAI(
api_key=os.environ["FIFTYNINE_API_KEY"],
base_url="https://api.59api.com/v1"
)

prompt = """You are a software localization specialist. Translate the JSON values into fr-FR. Return one valid JSON object only. Keep exactly the same keys. Preserve variables, ICU plural syntax, URLs, HTML entities, product names, and punctuation tokens. Glossary: workspace = espace de travail; 59API must remain 59API. Use concise UI wording."""

response = client.chat.completions.create(
model=os.environ["TRANSLATION_MODEL"],
temperature=0.2,
messages=[
{"role": "system", "content": "Follow the requested output format exactly."},
{"role": "user", "content": prompt + "\n\nSource JSON:\n" + json.dumps(source)}
]
)

translated = json.loads(response.choices[0].message.content)

A low temperature is important: localization should be consistent rather than creative. Batch related strings from the same screen together so the model can maintain terminology, but keep batches small enough that reviewers can understand each change.

Validate the Output Before Merging It

Never commit AI output without automated checks. First, confirm that it is valid JSON and contains exactly the expected keys. Next, compare protected tokens. For simple variables, a direct assertion is enough:

assert set(source) == set(translated)
assert "{name}" in translated["account.greeting"]

For ICU messages, use an ICU-aware parser rather than a basic regular expression, because plural expressions contain nested braces. Add linting to your CI pipeline, then render the localized build in a screenshot test or staging environment. Check truncation, right-to-left support where relevant, date and currency formats, and whether translated buttons still fit their containers.

Because 59API is designed as a low-cost relay without downgrading the underlying official models, it is a practical option for recurring localization pipelines, QA retries, and multi-locale releases. If you are ready to automate translations while retaining control through validation and review, sign up for 59API and test the workflow on one small locale catalog first.

Precios · Docs

¿Listo para empezar?

Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.

Registro gratis