Chapter 18·Shipping Translations·~9 min·
The Translation Pipeline: Strings, Files, and Memory
Localization pipelines extract source strings into structured exchange formats such as gettext PO, XLIFF 2.0, and ICU JSON. Complete sentence units, developer context notes, and consistent source phrasing govern translation quality and translation memory leverage.
Overview
Translators work in CAT tools using structured exchange files such as XLIFF 2.0, gettext PO, or ICU JSON rather than raw source code. How engineers extract strings, preserve sentence context, and attach translator notes directly determines translation quality and translation memory reuse.
Core rule
Externalize complete sentences with named placeholders and translator context notes, and keep source terminology consistent to maximize translation memory leverage.
Specification note: Concatenating fragments such as "Delete " + count + " files" breaks in Japanese and Turkish because those languages place the verb at the end of the sentence.
Failure mode
Translators work inside Computer-Assisted Translation (CAT) tools without direct access to the running application. When engineers concatenate sentence fragments in code or omit developer comments, translators must guess the grammatical context. For example, the English string Archive is a noun on a navigation tab but an imperative verb on an action button.
Inconsistent source copy also increases translation cost. Translation memory (TM) discounts repeated and fuzzy-matched segments across releases. Writing five slight variations of the same confirmation message forces vendors to translate and bill five new segments in every target language.
Managing translations in spreadsheets or code commits causes merge conflicts, loses Translation Memory (TM) discounts, and inflates localization costs.
Business stakes & user risk
Without Translation Memory, teams pay full per-word rates for unchanged strings every release, inflating annual translation budgets by 40% to 70%.
Rule of thumb
Automate string extraction in CI using standard formats (XLIFF, PO, ARB) and leverage Translation Memory fuzzy match tiers.
The Novice Trap vs. Production Standard
Contrast the intuitive assumption with the architecture required for global releases.
“Copying and pasting strings into a shared Google Sheet is an effective way to manage product translations.”
Naive approach: Manual spreadsheet exports
// Developer copies strings.json into Excel, emails agency, pastes back returned JSONDefect:Engineers accidentally overwrite fresh strings, placeholders get translated literally, and duplicate sentences are billed repeatedly.
Manual spreadsheets lead to broken format placeholders, untracked string deletions, and zero translation memory reusability.
Production standard: Automated TMS pipeline with Translation Memory
npm run i18n:extract && tms push --branch=main && tms pull --minimum-approval=reviewedBenefit:Continuous integration extracts strings, locks placeholders, preserves context notes, and applies 100% TM discounts automatically.
Cross-Functional Review Questions
Questions for product managers, designers, engineers, and testers to ask during sprint reviews.
“Are we utilizing Translation Memory (TM) and termbases to reduce translation costs across sprints?”
“Does our build pipeline extract strings automatically and validate placeholder integrity before deployment?”
“Do translators receive screenshots and contextual notes describing where strings appear in the UI?”
“Are translation file diffs inspected for missing keys or unexpected syntax changes before merging?”
Mechanism
String externalization and translator context
Localization pipelines operate on externalized message records. Each record consists of a stable identifier (cart.summary), a complete source sentence with named placeholders for variables, and a developer comment explaining where the string appears in the UI. Strings assembled at runtime through concatenation ('You have ' + count + ' items') never enter the message catalog as a complete sentence, which prevents translators from reordering clauses or applying target-language plural grammar.
Because translators work inside Computer-Assisted Translation (CAT) tools rather than the running application, an isolated English word such as Archive or Post is ambiguous between a noun heading and a verb button label. Supplying a context note and UI location with every string eliminates guesswork and reduces revision cycles after string freeze.
key: cart.summary
source: You have {count, plural, one {# item} other {# items}} in your cart.
placeholders: count (number, drives the plural)
context: Cart badge on the checkout header. "item" = a product,
not a menu item. Screenshot: checkout-header.pngInteractive demo
Guided exercises
- 1In "1 · Externalize first", select "Hardcoded" and read the "What the translator sees" pane. String extraction captures four disconnected fragments with hardcoded English plural logic and fixed word order.
- 2Switch to "Externalized". The extractor outputs a single structured message record with its key, ICU source template, typed placeholders, and context note.
- 3In "2 · One message, three file formats", open "gettext PO" and find the Plural-Forms line in the header. The header rule maps count `1` to `msgstr[0]` and all other counts to `msgstr[1]` for German, keeping target plural rules in the catalog file rather than application code.
- 4Switch to "XLIFF 2.0" and look for a plural construct. XLIFF 2.0 core does not define a dedicated plural tag, so the ICU plural expression travels inside `<source>` or is split into separate `<unit>` elements by the filter.
- 5In "3 · Translation memory prices repetition", click "Near repeat". Changing one word out of five yields an 80% fuzzy match against “Your file has been uploaded.”, pre-filling the stored German translation at a discounted rate.
- 6Type any new sentence into "Candidate string" and watch the Score column in the table. The TM compares the input against every stored segment: 100% reuses the stored target, 75% to 99% applies a fuzzy-match discount, and scores below 75% bill as new words.
1 · Externalize first
A string left in the code never reaches a translator. Switch versions and compare the “What the translator sees” pane.
// cart-summary.tsx
const label =
"You have " + count + " item" +
(count === 1 ? "" : "s") +
" in your cart.";What the translator sees
The sentence exists only at runtime. An extraction tool finds four fragments: "You have ", " item", "s", " in your cart."
The plural logic is English-only, and the word order is fixed in code, where no translator can change it.
Every downstream step (file export, translation memory, review, import) works on the externalized record, never on the code.
2 · One message, three file formats
The same two strings in each interchange format, as a German translator receives them.
msgid ""
msgstr ""
"Language: de\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#. Greeting on the account page. %s = first name.
#: src/account.c:52
#, c-format
msgid "Hello, %s!"
msgstr "Hallo, %s!"
#. Shown when an upload finishes.
#: src/upload.c:118
#, c-format
msgid "%d file uploaded"
msgid_plural "%d files uploaded"
msgstr[0] "%d Datei hochgeladen"
msgstr[1] "%d Dateien hochgeladen"Plurals
msgid_plural plus indexed msgstr[0], msgstr[1], … The Plural-Forms header declares how many forms the language has and which index each count maps to. German: nplurals=2; plural=n != 1.
Placeholders
Plain printf directives (%s, %d) inside the string. The #, c-format flag tells tools to check that the translation keeps them intact.
Context
#. extracted comments (written by the developer, exported by xgettext) and #: source references. The #, fuzzy flag marks entries a tool pre-filled from an old, similar msgid.
3 · Translation memory prices repetition
A translation memory stores every translated segment pair, and the tool scores each new source segment against them. The score decides whether the translator reuses, edits, or translates from scratch, and at what rate. Scores here are word-level edit distance (0–100). Each CAT tool computes its own, and no standard defines the bands.
Suggested translation Ihre Datei wurde hochgeladen.(check what changed)
The tool pre-fills the stored translation for the translator to edit, like an entry under gettext's #, fuzzy flag. Vendors typically bill it at a graduated discount that shrinks as the score drops.
| Stored source (en) | Stored target (de) | Score |
|---|---|---|
| Your file has been uploaded. | Ihre Datei wurde hochgeladen. | 80 |
| Your file could not be uploaded. | Ihre Datei konnte nicht hochgeladen werden. | 33 |
| Delete this file? | Diese Datei löschen? | 0 |
| Your password has been changed. | Ihr Passwort wurde geändert. | 60 |
| Payment failed. Please try again. | Zahlung fehlgeschlagen. Bitte versuchen Sie es erneut. | 0 |
| Settings saved. | Einstellungen gespeichert. | 0 |
A rewording is paid for again in every target language: “Your file was uploaded.” scores 60 against the stored “Your file has been uploaded.”, below the fuzzy band, so it is billed as new words.
Implementation rules
- Externalize complete sentences with named placeholders. Store each sentence as a single catalog entry using named variables and ICU
pluralorselectblocks. Never concatenate sentence fragments in code. - Attach developer context to every catalog entry. Specify UI component placement, character limits, and grammatical part of speech using
#.extracted comments in gettext PO,<note>elements in XLIFF, or@key.descriptionmetadata in ARB and JSON. - Use standard localization interchange formats. Exchange catalogs as XLIFF 1.2 or 2.0, gettext PO, or ICU JSON so CAT tools lock placeholders and validate syntax automatically. Avoid ad-hoc spreadsheets and CSV files.
- Standardize source terminology to maximize TM leverage. Consistent source strings generate 100% and 101% In-Context Exact (ICE) matches, reducing per-word cost and preserving terminology.
- Enforce a string freeze before vendor handoff. Batch copy edits before starting a translation round so late source changes do not invalidate in-progress translations across markets.
Operational context
Roles
Workflow stages
- ·Reviewing user-facing strings in pull requests
- ·Configuring TMS file connectors and string extraction
- ·Estimating translation budgets and schedules
Use the tool: Budget estimator · price a translation round →
Production incident
The GNU gettext manual devotes a dedicated section to prohibiting string concatenation. It demonstrates why assembling 'Replace X with Y?' through separate string copies breaks translation, and mandates a single format string so translators can see the full sentence and reorder the placeholders when the target grammar requires it.