All articles
8 min read

Pseudo-Localization: Catch i18n Bugs Before You Pay for a Single Translation

How pseudo-localization fakes translation to expose hardcoded strings, truncation and encoding bugs, with a TypeScript transform and a checklist.

Testingi18nLocalization

Your German translations come back a week before launch, you drop them in, and a button that said "Settings" now says "Einstellungen" and no longer fits inside its container. Nobody is at fault here – the English word is eight characters and the German one is thirteen, and nothing in your testing ever showed anyone a thirteen-character label in that spot. You paid a translator to find out your layout was never designed for this, which is a backwards way to learn it.

Pseudo-localization moves that discovery earlier, and makes it free. It replaces your source strings with a fake "translation" that looks unmistakably foreign, is still readable by an English-speaking developer, and is engineered to be longer than the original – so every layout, encoding, and hardcoded-string problem shows up on day one of a feature, not in the week before release.

What it actually is

A pseudo-localization pass takes your source locale and transforms it along a few axes at once, deliberately:

Accented look-alikes. Latin letters get swapped for accented cousins that read the same word to an English speaker but render as un-mistakably not-English: a becomes à, e becomes é, s becomes š. "Settings" becomes something like "Séttíñğš" – still legible, visibly transformed.

Length expansion. Translated text runs longer than English more often than it runs shorter, and the effect is worst on short strings, where there's no room to absorb the difference. German is the classic offender for compound nouns; even in languages that average shorter, short UI labels specifically tend to expand because a two-word English label often needs a short phrase elsewhere. A reasonable rule of thumb used across the industry is to pad by roughly 30 to 40% for an average string and allow closer to 100% headroom on very short ones, which is why a good transform pads proportionally more on short input.

Bracket markers. Wrapping each pseudo-localized string in brackets – [Séttíñğš] – marks exactly where one translatable unit starts and ends on screen. If a bracket is missing, or a bracket appears in the middle of what should be one sentence, you've found a string that was assembled from parts in code rather than translated as a whole.

An optional mirrored pseudo-locale. A second pass reverses the string and marks it for right-to-left rendering, so you can sanity-check RTL layout behaviour without anyone on the team actually speaking Arabic or Hebrew. It catches a different class of bug from the accented pass – mirroring and bidi issues rather than length and hardcoding – and is worth a separate locale rather than combining both transforms into one.

What it catches, and why each one matters

Hardcoded strings. This is the big one. Any text that didn't go through your i18n layer stays in plain English, surrounded by pseudo-localized text that didn't. It's the single easiest bug class to spot visually, and it's the one that's genuinely invisible in a normal English-only QA pass, because the hardcoded string looks completely correct in English.

Truncation and layout breakage. The expanded, bracketed string shows you exactly which labels, buttons, and table headers don't have room to grow. You find this on a feature branch instead of in a translator's bug report.

Concatenation bugs. If a sentence is built from pieces in code – "Welcome, " + name + "!" – the bracket markers show two or three disconnected pseudo-localized fragments sitting next to an untouched name, instead of one bracketed unit. A correctly externalised message with a placeholder shows one bracketed string with the placeholder embedded inside it.

Encoding and font problems. Accented and non-Latin characters exercise your font stack and your encoding pipeline the same way a real Polish or Vietnamese translation would, well before any of it exists. A ? or a tofu box (a rendered missing-glyph box) in a pseudo-localized screen is the same bug you'd otherwise find in production in whatever language first needs that character.

Sorting assumptions. Code that assumes ASCII ordering, strips "non-standard" characters, or validates input against an English-only character class tends to break visibly once strings contain diacritics – which is a cheap way to catch an assumption that would otherwise only surface once real Polish, Turkish, or Vietnamese text reaches the same code path.

None of these bugs are exotic. They're the ordinary, boring defects every team ships, and the only reason they survive to production is that nobody looked at the screen in a state where they'd be visible. A pseudo-localized build makes that state the default one your QA process sees, instead of a rare condition that only happens once translation is real and the schedule has no slack left to fix it.

A small working transform

Here's a flat-JSON pseudo-localizer that handles the two things that most naive scripts get wrong: it leaves placeholders alone, and it pads proportionally rather than by a fixed amount.

const ACCENTS: Record<string, string> = {
  a: 'à', e: 'é', i: 'í', o: 'ó', u: 'ü',
  A: 'À', E: 'É', I: 'Í', O: 'Ó', U: 'Ü',
  n: 'ñ', s: 'š', c: 'ç', y: 'ý', g: 'ğ',
};

const PLACEHOLDER = /\{[^}]*\}|%[sd]|%\([^)]+\)s/g;

function accent(text: string): string {
  return text.replace(/[A-Za-z]/g, (ch) => ACCENTS[ch] ?? ch);
}

// Pad proportionally more on short strings, where real translations
// tend to expand the most relative to source length.
function expansionFactor(length: number): number {
  if (length <= 10) return 0.6;
  if (length <= 30) return 0.4;
  return 0.3;
}

function pad(text: string): string {
  const extra = 'Ñøñø'.repeat(Math.ceil((text.length * expansionFactor(text.length)) / 4));
  return `${text} ${extra.slice(0, Math.ceil(text.length * expansionFactor(text.length)))}`;
}

function pseudoLocalize(value: string): string {
  // Pull placeholders out before transforming, so `{name}` or `%(count)s`
  // survive byte-for-byte instead of being accented into something your
  // app can no longer parse.
  const tokens: string[] = [];
  const withoutTokens = value.replace(PLACEHOLDER, (match) => {
    tokens.push(match);
    return `\u0000${tokens.length - 1}\u0000`;
  });

  const transformed = pad(accent(withoutTokens));

  const restored = transformed.replace(/\u0000(\d+)\u0000/g, (_, i) => tokens[Number(i)]);

  return `[${restored}]`;
}

export function pseudoLocalizeFile(source: Record<string, string>): Record<string, string> {
  const out: Record<string, string> = {};
  for (const [key, value] of Object.entries(source)) {
    out[key] = pseudoLocalize(value);
  }
  return out;
}

Run against a small source file:

{
  "cart.empty": "Your cart is empty",
  "cart.greeting": "Welcome back, {name}"
}

the output looks like:

{
  "cart.empty": "[Yóür çàrt íš émptý ÑøñøÑøñø]",
  "cart.greeting": "[Wélçómé bàçk, {name} ÑøñøÑøñ]"
}

{name} survived untouched because it was swept out before the accent pass and put back afterward, exactly the same technique used to protect placeholders when translating JSON files with AI. Everything else is visibly, deliberately foreign, longer than the source, and bracketed at the edges.

The naming convention: en-XA, ar-XB

If you want this to interoperate with existing tooling rather than invent your own locale code, follow the convention several platforms already use: en-XA for the accented, expanded, bracketed pseudo-locale, and ar-XB for the mirrored, right-to-left one. Android has shipped pseudolocales under exactly these codes since API 18, togglable with a single build flag, and the same naming shows up elsewhere in the industry for the same reason – XA and XB are in the range ISO 3166 reserves for user-assigned codes, so they won't collide with a real language. Using the same codes your mobile build already understands means one pseudo-locale concept covers your web and native surfaces instead of two incompatible ones.

Making it routine

Pseudo-localization is only useful if it runs often enough that a regression gets caught before it ships, not once a quarter as a special exercise. The natural place is a dedicated QA build: generate the en-XA file as part of your pipeline, point a staging environment at it, and have someone click through the main flows looking at screenshots rather than reading every string. It's a visual check far more than a reading one – you're looking for a bracket that's missing, a plain English word sitting among accented text, or a button that's lost its label to ellipsis.

A concrete example worth keeping in mind while reviewing: a "Save changes" button that renders cleanly in English at 12 characters can be the first thing to break once it becomes [Sàvé çhàñğéš ÑøñøÑ] at twenty. If the button clips the text instead of wrapping or growing, that is not a translation problem waiting to happen in German – it is a layout problem that already exists today, and pseudo-localization is just the first moment anyone noticed.

The pseudo-locale loop

  1. Pull the source stringsCI
    npx @translatize/cli pull
  2. Generate en-XACI

    Run the transform above over the source file. It never goes back up – it only feeds the preview build.

  3. Build a preview in en-XACI

    A staging build that loads the pseudo-locale as if it were a real language.

  4. Click through and screenshotQA

    Look for missing brackets, plain English among accented text, and clipped labels.

  5. Record limits on the cramped keysYou

    Set a character limit on each key that ran out of room, so translators and reviewers see it from then on.

Where this fits naturally with Translatize: pull your source file with the CLI exactly as you would for any other task (npx @translatize/cli pull), run it through a transform like the one above, and point a preview build at the result. Nothing about the loop is heavy – it's the same source file you already have, run through a script before a build. The pseudo-locale only ever exists in that preview build; nothing fake is written back to the project, so translators never see it. If the feature lives on its own branch, pull with that branch's token and the preview shows exactly the strings the feature adds.

When the review turns up a string that's cramped at 130% of its English length, that's a concrete, reusable fact about the key, not just a one-off bug. Record it as the character limit on that key, so the constraint travels with the key from then on – a translator writing that value later, or a reviewer deciding whether to approve it, sees the same limit a reviewer just discovered by hand, instead of everyone rediscovering it independently in whatever language happens to be the first one actually translated.

In Translatize that limit does more than inform. AI translation is given it as context when it drafts the value, and the character-limit quality check flags any translation that still runs over it, in every language, without anyone having to measure strings by eye.

A short list for Monday

  • Generate en-XA as a build artefact, not a one-off script someone runs before a big release.
  • Protect placeholders before transforming, and verify they survive, with an automated check rather than a visual one.
  • Review screenshots, not strings in isolation – truncation is a layout problem and layout problems only show up rendered.
  • Do the pass on a branch, record what it finds as character limits on the keys that failed, and let that constraint carry forward into real translation.
  • If you have the appetite for it, add a mirrored ar-XB pass once the accented one is clean – it catches a genuinely different bug class from expansion, and is worth doing before you ship right-to-left layout at all.

None of this replaces real translation review, and it isn't supposed to. It just means the bugs a real translator finds are about meaning, not about a label that was never going to fit. For the placeholder and plural mechanics this protects, the ICU message format guide covers the syntax a pseudo-locale build won't validate on its own, and if your UI is built in React, the React i18n guide covers wiring a second locale like en-XA into the same component tree you already have.

Keep reading