InternationalisationVol. 23 · i18n
0 / 0

Shelves / Internationalisation

IN·05

Translating the Interface

How text gets from code to translators and back without breaking: externalised messages and resource formats on the web, Android and iOS, why sentences must never be built from fragments, ICU MessageFormat for plurals, gender and selection, context for translators, text expansion and layouts that survive it, pseudo-localisation, the translation pipeline from extraction through translation memory, machine and LLM translation to in-context review, per-app language settings, and localised URLs; with a lab that renders one button label in five languages and a pseudo-locale in Chromium.

18 topics · ~13 min read · 16-question quiz
Updated Suggest a correction

Start here: the button that didn't fit

TiffinBox's "Skip tomorrow's lunch" button was designed in English at a fixed 180 px width. The lab rendered the translated labels in Chromium with the same 16 px font:

Language Label Text width vs English Fixed 180 px button Flexible button (max 280 px)
English Skip tomorrow's lunch 156 px 100% fits 1 line
German Mittagessen für morgen überspringen 266 px 170% clipped 2 lines
Hindi कल का दोपहर का भोजन छोड़ें 167 px 107% clipped 1 line
Tamil நாளைய மதிய உணவைத் தவிர்க்கவும் 250 px 160% clipped 1 line
Telugu రేపటి మధ్యాహ్న భోజనాన్ని దాటవేయండి 301 px 193% clipped 2 lines
pseudo-locale [!!! Šķíƥ ţöɱöŕŕöŵ’š ļûñçĥ ··········· !!!] 265 px 170% clipped 2 lines

Every translation was clipped by the fixed button; the flexible one survived all of them by wrapping. The pseudo-locale, generated automatically from English, failed the fixed button in the same way, before any translator was involved.

(Widths depend on fonts; the lab machine used its fallback fonts for Indic scripts, which are wider than a phone's Noto fonts. The ranking and the clipping are the lesson, not the exact pixels.)

Translating an interface is an engineering pipeline: messages written so they can be translated, layouts that tolerate any length, data flowing to translators with context and back with checks. This chapter builds that pipeline.

How deep to go

Volume 17 defines six mastery levels. For translating the interface:

Level What you can do
L1 Put all user-visible text in resource files instead of code
L2 Write messages with placeholders, plurals and context; build layouts that tolerate expansion
L3 Explain message formats, pseudo-localisation and the translation pipeline
L4 Find i18n bugs (concatenation, clipping, missing context, placeholder errors) through tests and reviews
L5 Design continuous localisation for a product: tooling, workflow, quality gates, machine translation policy
L6 Run localisation for many products and dozens of languages, including terminology and vendor management

Externalise every string

Every user-visible string lives in a resource file, keyed, never in code. That includes button labels, error messages, emails, push notifications, accessibility labels, alt text, validation messages from the server, and units. The code refers to a key; the runtime picks the user's language.

Platform Format Plurals and selection
Android res/values/strings.xml, res/values-hi/strings.xml, … <plurals> with CLDR categories; getQuantityString
iOS / macOS String Catalogs (.xcstrings, which replaced .strings/.stringsdict) plural and device variants inside the catalog
Web (JavaScript) JSON or YAML with ICU MessageFormat (FormatJS / react-intl, i18next with ICU), or Fluent (.ftl) ICU plural, select
Server (Java, Kotlin) .properties resource bundles with ICU4J MessageFormat ICU
Python, PHP, C gettext .po / .mo ngettext with per-language plural formula
Flutter ARB files (ICU syntax) ICU

Keys: use stable, descriptive IDs (plan.skip_tomorrow.button) rather than English text as the key, so fixing an English typo doesn't invalidate every translation. Some systems (gettext, some FormatJS setups) use the source text plus a context string as the key; that works if the tooling handles changes.

Server-generated text (emails, notifications, error messages, PDF invoices) needs the user's locale, stored on their profile, not the server's or the request's. Errors returned by APIs should carry a machine-readable code plus parameters; the client formats the message in its language.

Never build sentences from pieces

Concatenation hard-codes English grammar:

Text
"You have " + n + " meals left this week"        ✘
"Delivered by " + rider + " at " + time          ✘
getString(R.string.skip) + " " + dayName         ✘

Translators receive fragments ("You have", "meals left this week") without knowing they belong together; other languages put the verb last, the number first, or change the noun form with the number. Write whole sentences with named placeholders:

Text
plan.meals_left = {count, plural,
    =0 {No meals left this week}
    one {# meal left this week}
    other {# meals left this week}}

delivery.done = Delivered by {rider} at {time}

Named placeholders ({rider}) rather than positional ones (%s) let translators reorder them and understand them. Format numbers, dates and currency inside the message with the locale ({time, time, short}, {price, number, ::currency/INR}) or pre-format them with the locale's formatter before substitution.

Also avoid: reusing one string in two places because the English happens to match ("Open" the verb on a button, "Open" the status on a kitchen); text in images; building lists by hand (use list formatting); and capitalisation or truncation in code ("first letter uppercase" is meaningless in Hindi and wrong in German, where nouns are capitalised).

ICU MessageFormat

ICU MessageFormat is the most widely supported message syntax. Its building blocks:

Construct Example Chooses by
{name} Hello {name} substitution
{n, number} / {d, date, medium} {price, number, ::currency/INR} locale formatting
{n, plural, …} one {# meal} other {# meals} CLDR plural category; =0 for exact matches
{n, selectordinal, …} one {#st} two {#nd} few {#rd} other {#th} ordinal category
{g, select, …} female {She} male {He} other {They} any keyword (gender, role, platform)

Translators supply the categories their language needs: an Arabic translation of the plural message has six branches, a Japanese one has only other. Your tooling must allow that and validate it (a Russian translation missing few is a bug).

Grammar beyond plurals: many languages inflect nouns by case (the dish name changes form after "with" or "for" in Russian, Tamil or Finnish) and adjectives and verbs by gender. Messages that insert nouns into sentences ("Add {dish} to the study plan") therefore can't always be translated correctly. Mitigations: rephrase to a label-and-value form (Add to the study plan: {dish}), provide gender or case variants via select, or let translators define grammatical properties of inserted terms.

MessageFormat 2 (Unicode's redesigned syntax, finalised in 2025 and arriving in ICU and JavaScript libraries) adds clearer syntax, multiple selectors and custom functions. Fluent (Mozilla) has similar goals. New projects can adopt either where tooling supports it; ICU MessageFormat 1 remains the safe default.

Context for translators

Translators work from strings in a tool, often without seeing your app. Each string should carry:

  • a description: where it appears, what it does, noun or verb ("Button on the plan screen; skips tomorrow's delivery");
  • placeholder explanations and examples ({rider}: the delivery rider's first name, e.g. "Ravi");
  • length limits where they truly exist (notification titles, SMS, App Store fields);
  • screenshots, ideally captured automatically by UI tests in every screen state;
  • a glossary of product terms (is a "plan" a योजना or a प्लान?) and a style guide (formal or informal "you": आप vs तुम, Sie vs du).

Android's tools:comment/description attributes, iOS catalog comments, FormatJS description fields and gettext #. comments all carry this to the tools.

Layouts that survive translation

Translated text is usually longer than English, especially in short strings:

English length Typical expansion
up to 10 characters 100–300%
11–20 80–200%
21–70 40–80%
more than 70 ~30%

(These widely used rules of thumb come from localisation practice; actual growth depends on language pair, script and font, and some languages, such as Chinese, are shorter.) The lab's 21-character label grew 70% in German and 93% in Telugu.

Design rules:

  • No fixed widths or heights for text containers. Let buttons, chips and tabs grow and wrap; set minimums, not exact sizes.
  • Allow wrapping and test two- and three-line labels; avoid white-space: nowrap and maxLines = 1 on important text.
  • Leave room for taller scripts: Devanagari, Thai and Arabic have marks above and below the line; tight line-height clips them.
  • Use the platform's text and layout systems (Compose, SwiftUI, CSS flex/grid), which handle scripts and wrapping.
  • Truncate only as a last resort, at grapheme boundaries, with the full text available (tooltip, detail view, accessibility label).
  • Mirror layouts for RTL (chapter 06).
  • Test the longest translation of each screen, plus large accessibility font sizes, which multiply the problem.

Pseudo-localisation

Pseudo-localisation creates a fake locale from your source strings automatically:

Transformation Finds
replace letters with accented look-alikes (Šķíƥ) hard-coded strings (still plain), encoding bugs (mojibake), fonts without accented glyphs
pad by 30–50% (···········) clipping, overflow, fixed widths
wrap in brackets ([!!! … !!!]) concatenation (brackets appear mid-sentence) and truncation (missing closing bracket)
mirror to right-to-left (Android ar-XB) layout direction bugs

Android has built-in pseudo-locales (en-XA for accented and expanded, ar-XB for right-to-left; enable pseudoLocalesEnabled). Xcode's scheme options include double-length and right-to-left pseudo-languages. On the web, FormatJS and i18next have pseudo-locale plugins, or a 30-line script does it. Run the whole UI test suite and screenshot tests in a pseudo-locale in CI; it's the cheapest i18n test there is.

The translation pipeline

Text
developer adds/changes a string ─► extraction in CI ─► TMS ─► translators / MT + review ─► checks ─► merged back ─► build or over-the-air update
  1. Extraction: CI collects new and changed strings (with context) and pushes them to a translation management system (TMS) such as Crowdin, Lokalise, Phrase, Smartling or Transifex, or an open-source one like Weblate.
  2. Translation memory and glossary: the TMS reuses earlier translations of identical or similar segments (translation memory) and enforces terms (glossary). This keeps wording consistent and cuts cost.
  3. Translation: by professional translators, by machine translation (MT) with human post-editing, or by community. Large language models now produce good drafts and can follow a glossary and style guide, but they still mistranslate ambiguous short strings, invent placeholders, change tone and can't see the screen. Treat machine output as a draft: have qualified reviewers check it in context, starting with high-impact text (payments, legal, safety, onboarding), and measure quality over time.
  4. Automated checks: placeholders match the source, ICU syntax parses, required plural categories exist, length limits hold, no untranslated source text slipped through, consistent terminology.
  5. In-context review: reviewers see screenshots or a staging build in their language and report issues.
  6. Merge and release: translations return as pull requests or build artefacts. Missing translations fall back to the default language per string, never as raw keys.

Continuous localisation runs this on every change, so translations keep pace with development; release trains may still have a "string freeze" a few days before release. Mobile apps can fetch updated strings over the air from the TMS's CDN, fixing a typo without an app release; restrict this to text (not layout or logic), keep a bundled fallback, and sign or pin the source.

Beyond strings

  • Images and video with embedded text need localised versions; prefer text overlays rendered by the app.
  • Examples and defaults: names, addresses, phone numbers and dishes in examples should fit the market.
  • Cultural meaning of colours, icons and gestures varies (a thumbs-up, the colour white, a mailbox icon that only looks like a US mailbox).
  • Legal content (terms, privacy notices, consumer rights, tax invoices) is localised by legal review, not just translation.
  • App store listings, screenshots, emails, SMS templates and support articles are all part of the product.
  • Accessibility: set the document language (<html lang="te">, and lang on mixed-language spans) so screen readers pronounce text correctly.

Choosing and switching language

  • Default to the OS or browser language preferences (chapter 04's negotiation).
  • Let users override in the app. Android 13+ supports per-app language (AppCompatDelegate.setApplicationLocales, locales_config.xml); iOS offers per-app language in Settings. Persist the choice server-side too, for emails and notifications.
  • Switch at runtime without restarting the session, where the framework allows.
  • Web URLs: give each language its own URL (/hi/menu, hi.tiffinbox.in), link alternatives with hreflang for search engines, and don't redirect by IP without a way back.

Common traps

  • Hard-coded strings, including in server errors and notifications.
  • Concatenated sentences and positional placeholders.
  • English-only plural logic.
  • Reusing a string in two contexts.
  • Fixed-size text containers and single-line constraints.
  • No context or screenshots for translators.
  • Shipping raw machine translation in critical flows.
  • Falling back to keys instead of the default language.
  • Forgetting lang attributes, store listings and emails.

Lab: one label, six languages

Setup. Chromium (headless, via Playwright 1.x on Node.js 22) renders the "Skip tomorrow's lunch" label in English, German, Hindi, Tamil, Telugu and an automatically generated pseudo-locale, each three ways: as plain text (to measure its width), inside a fixed 180 px button with white-space: nowrap; overflow: hidden, and inside a flexible button with max-width: 280px that may wrap. Font: 16 px sans-serif. The translations were written for the lab (a translator might phrase them differently), and the lab machine draws Indic scripts with its fallback fonts (FreeSerif/Unifont-family), which are wider than a phone's Noto fonts. Absolute widths will differ on devices; the comparison holds.

Results

Label Text width vs English Fixed 180 px Flexible, max 280 px
en: Skip tomorrow's lunch 156 px 100% fits 38 px tall (1 line)
de: Mittagessen für morgen überspringen 266 px 170% clipped 56 px (2 lines)
hi: कल का दोपहर का भोजन छोड़ें 167 px 107% clipped 38 px (1 line)
ta: நாளைய மதிய உணவைத் தவிர்க்கவும் 250 px 160% clipped 38 px (1 line)
te: రేపటి మధ్యాహ్న భోజనాన్ని దాటవేయండి 301 px 193% clipped 56 px (2 lines)
pseudo: [!!! Šķíƥ ţöɱöŕŕöŵ’š ļûñçĥ ··· !!!] 265 px 170% clipped 56 px (2 lines)

What it shows

  • A fixed-width control fails for every translation, even Hindi at only 7% longer, because English was designed with almost no spare room (156 px of 164 px usable).
  • Wrapping fixes all of them, at the cost of a taller button: the layout around it must allow that.
  • Indic scripts can be much wider than English at the same font size, even when the word count is similar.
  • Pseudo-localisation predicted the failure without a single real translation: it expanded the label by 70% and clipped exactly like German.

Try it yourself

  1. Write a pseudo-localiser: map a–z to accented look-alikes, pad by 40%, wrap in [!!! … !!!], and preserve {placeholders}. Run it over a real app's strings.
  2. Turn on Android's en-XA and ar-XB pseudo-locales (Developer options, after pseudoLocalesEnabled true) and walk through an app.
  3. Change the fixed button to min-width: 180px and check every label.
  4. Install Noto Sans Telugu and Noto Sans Tamil, rerun, and compare widths with the fallback fonts.
  5. Set line-height: 1 on the Hindi and Telugu labels and look for clipped vowel signs above and below the line.

Revision sheet: translating the interface

Key ideas

  • Externalise every user-visible string, including server errors, emails, notifications and accessibility labels; use stable keys.
  • Whole sentences with named placeholders; never concatenate; format numbers and dates inside messages with the locale.
  • ICU MessageFormat: plural, selectordinal, select; translators add the categories their language needs; MessageFormat 2 and Fluent are newer options.
  • Give translators context: descriptions, placeholder examples, limits, screenshots, glossary, style guide.
  • Layouts must grow and wrap; expect 30–300% expansion; leave vertical room for scripts with marks.
  • Pseudo-localise in CI (accents, expansion, brackets, RTL).
  • Pipeline: extraction → TMS (translation memory, glossary) → human or machine translation with review → automated checks → in-context review → merge; per-string fallback; over-the-air text updates on mobile.
  • Per-app language choice; language-specific URLs with hreflang; lang attributes.

Numbers to remember

  • Lab expansion of a 21-character label: German 170%, Tamil 160%, Telugu 193%.
  • Short strings (≤10 characters) can grow 100–300%.

Glossary

  • Resource file: a file of keyed, translatable strings.
  • ICU MessageFormat: message syntax with placeholders, plurals and selection.
  • TMS: translation management system.
  • Translation memory: stored past translations for reuse.
  • Post-editing: human correction of machine translation.
  • Pseudo-localisation: an automatic fake translation used for testing.
  • String freeze: a cut-off for text changes before a release.
  • hreflang: HTML/HTTP annotation linking language versions of a page.