DEV Community

Hugo Bernardo Cardoso
Hugo Bernardo Cardoso

Posted on

Benchmark: AI Translation Quality on JSON, CSV, and PO Files—Accuracy and Speed Compared

Benchmark: AI Translation Quality on JSON, CSV, and PO Files—Accuracy and Speed Compared

If you've ever shipped a translated app that crashed at runtime because {player_name} turned into {player_Nom} or a %s placeholder became % s, you know the real cost of AI translation isn't the API bill—it's the broken release.

Most AI translation benchmarks measure fluency. They ask: does the translation read naturally? That's the wrong question for product files. The right question is: does the translated file still work?

We ran a benchmark across the three file formats that dominate product localization—JSON, CSV, and PO—to measure what actually matters: accuracy, variable integrity, and throughput.


LocaFileAi engines

The Setup

We tested three translation approaches against a representative product file in each format:

  1. Raw AI translation — send the file content directly to the model
  2. Manual variable masking — replace variables with tokens before translation, restore after
  3. LocaFile AI's variable-locking pipeline — automated lock, translate, unlock

Each file contained realistic content: UI strings, error messages, plural forms, and markup tags. The variable density was deliberately high—production files are rarely clean prose.


JSON: Where Nested Keys and Interpolation Collide

JSON is the default format for web and mobile apps, and it's where naive translation fails most visibly.

The problem: A typical React or Vue locale file mixes plain strings with interpolated values:

{
  "welcome": "Welcome back, {username}!",
  "items": {
    "count": "You have {count} items",
    "empty": "Your cart is empty"
  },
  "error": {
    "timeout": "Request timed out after %d seconds"
  }
}
Enter fullscreen mode Exit fullscreen mode

Raw AI translation produced two failure modes:

  • Placeholder mutation: {username} became {nombre_de_usuario} in Spanish—semantically reasonable, functionally broken. The app rendered the literal string {nombre_de_usuario} instead of the username.
  • Key drift: In longer files, the model occasionally "helpfully" renamed keys to match translated values. The app then fell back to English or crashed on missing keys.

The result:

Approach Variable integrity Key integrity Time (1000 strings)
Raw AI 82% 91% 14s
Manual masking 97% 99% 22s (incl. setup)
LocaFile AI 100% 100% 16s

Manual masking works but requires writing and maintaining a regex-based masking script—and every new variable pattern in your codebase breaks it. LocaFile AI's VariableLocker.php handles {variable}, %s, %d, and nested interpolation patterns automatically.


CSV: The Silent Format Killer

CSV looks simple. It isn't. Godot, Unity, and generic CSV exports all have quirks that raw translation destroys.

The problem: CSV files used in game engines often contain format specifiers and inline markup:

id,en,de
greeting,"Hello, {player_name}!",""
level_up,"Level up! +{0:plural:one={1} point|other={1} points}",""
tooltip,"<b>HP</b>: {hp}/{max_hp}",""
Enter fullscreen mode Exit fullscreen mode

Raw AI translation broke CSV in three ways:

  • Comma injection: Translated text introduced unescaped commas, shifting columns and corrupting the entire row alignment
  • Plural destruction: {0:plural:one=...|other=...} patterns were flattened or partially translated, breaking the engine's plural resolution
  • Markup mangling: <b> tags were translated as text or dropped entirely

The result:

Approach Row integrity Variable integrity Time (500 rows)
Raw AI 74% 79% 9s
Manual masking 93% 95% 18s
LocaFile AI 100% 100% 11s

The manual approach required a custom CSV parser to handle escaped commas and quoted fields—essentially reimplementing what a proper localization tool should do.


PO: Gettext's Strict Grammar

PO files are unforgiving. They have a defined structure, metadata headers, and plural forms that must match the target language's rules.

The problem: A standard PO entry:

msgid "You have %d new messages"
msgid_plural "You have %d new messages"
msgstr[0] ""
msgstr[1] ""
Enter fullscreen mode Exit fullscreen mode

Raw AI translation produced two critical failures:

  • Plural form mismatch: For a target language with three plural forms (like Russian or Arabic), the model sometimes generated only two msgstr entries—the file then failed to compile
  • Metadata corruption: The Content-Type header and Plural-Forms declaration were occasionally "translated," breaking the file's encoding declaration

The result:

Approach Compile success Plural integrity Time (300 entries)
Raw AI 68% 72% 7s
Manual masking 89% 94% 15s
LocaFile AI 100% 100% 9s

Manual masking for PO requires understanding gettext's plural rules per language—a significant investment if you're targeting more than one or two languages.


What the Benchmark Actually Proves

Accuracy without variable protection is an illusion. A 95% translation quality score is meaningless if 5% of your placeholders break and crash the app. The failure rate compounds across languages: translate into 10 languages and the probability of at least one broken variable approaches certainty.

Speed is secondary to correctness. The raw AI approach was fastest in every test—until you factor in the debugging time. Every corrupted placeholder becomes a support ticket, a crash report, or a one-star review.

The format matters less than the pipeline. JSON, CSV, and PO have different failure modes, but the root cause is identical: the AI treats your file as prose when it's actually code with human-readable strings embedded.


The Practical Takeaway

If you're a solo developer or small team shipping a product that changes regularly, you have two realistic options:

  1. Build your own masking pipeline — you'll spend days handling edge cases per format, and every new variable pattern in your codebase becomes a maintenance burden
  2. Use a tool that locks variables before translation — LocaFile AI does this automatically, supports 15+ formats including Godot, Unity, Unreal, Android, iOS, Laravel, Flutter, Ren'Py, and subtitles, and requires no login or monthly commitment

The benchmark numbers are clear: raw AI translation breaks 18–32% of files in production formats. That's not a quality problem—it's a release risk.

LocaFile AI's approach is different: variables are replaced with opaque lock tokens before the AI sees the content, then restored afterward. The AI translates what it should—the human-readable strings—and never touches what it shouldn't.

You can test it yourself with a free five-string preview and syntax analysis before paying anything. Upload a file, see the variable protection in action, and check whether your placeholders survive translation.

Because the only benchmark that matters is the one where your app doesn't crash when your users switch languages.

Top comments (0)