Message Catalogs: Formats, Round Trips, and CI Gates

Message Catalogs: Formats, Round Trips, and CI Gates

A message catalog serves the runtime and the translation toolchain at once. Formats by capability, the extraction round trip, and the CI gates that catch one-locale bugs.

Translation file formats matter less than format debates suggest, because a message catalog serves two audiences with different needs: the runtime and the translation toolchain. This article covers the catalog as an engineered artifact: the format landscape read by capability, a single source of truth, the extraction round trip between code and translators, and the CI gates that keep every locale releasable, placeholder parity above all in our view.

Catalogs are build artifacts with two audiences

A message catalog is read by two systems that want different things.

The runtime wants fast lookup and a small payload: a key, a message, nothing else, ideally pre-parsed and split so a page loads only the messages it uses.

The translation toolchain wants the opposite: context for each string, a description of where it appears, the placeholder types, a record of whether a translation is new, translated, or reviewed, and notes between translator and developer.

One source of catalog pain is forcing one file to serve both. Teams that ship their translator-facing file straight to the browser end up either stripping metadata the translators needed, or shipping metadata the browser never reads.

The working consequence is that the interchange representation and the runtime representation are allowed to differ. The file translators work in can be rich in metadata; the file the runtime loads can be compiled from it, flattened, pre-parsed, and split by route. "Compile the catalog" is a legitimate build step, the same way compiling TypeScript is, not overengineering.

The catalog is also the deliverable boundary of the whole i18n system. Everything the key-architecture article put into keys, namespaces, and context descriptions travels outward through these files, and everything translators produce comes back through them. If the files are unreliable, nothing upstream or downstream can compensate.

The scope line: translator workflow, review practice, and translation-platform procurement are the localization operation's territory. This article owns the files, the round trip, and the gates.

The format landscape, by capability

No format wins on every axis, so the useful comparison is by capability rather than by rank. The table reads four common formats against five capabilities, one per column.

FormatPlurals and ICU messagesContext and descriptionsTranslation state trackingTooling ecosystemDiff-ability in code review
JSON dialects (flat or nested)ICU strings embedded as valuesDefined by some dialects (for example ARB and Chrome extension messages.json); otherwise by convention or sidecar filesNot built inNative to every JavaScript toolchainGood for flat files, noisier for deep nesting
XLIFFCarries ICU strings or its own inline markupNotes and context fields built inBuilt-in optional state per segmentAn OASIS standard for localization interchangeVerbose; readable but heavy
gettext POIts own plural forms mechanism`msgctxt` and translator comments built inA fuzzy flag, plus obsolete (commented-out) entriesLong-established toolchain lineageGood; line-oriented and reviewable
FluentIts own syntax with selectorsComments per messageNot built inSmaller, focused ecosystemGood; designed to be human-edited

JSON dialects are native to the web stack. Frictionless in JavaScript toolchains, trivial to load, easy to diff when flat. They are weakest at exactly what translators need: JSON itself has no standard place for context, description, or translation state. Some dialects define description fields, such as Chrome extension messages.json (a message plus a description) and ARB (an @key entry with description and context); neither defines a translation state. Outside such dialects, conventions fill the gap, such as a parallel description file, and they differ from team to team.

XLIFF, standardized by OASIS (XLIFF 2.1), is an interchange format designed to carry localizable data from one step of the localization process to the next and between tools. Each unit can carry notes and holds one or more segments, each with a source, an optional target, and an optional state (initial, translated, reviewed, or final). It is a strong option for round-tripping with external translators and translation platforms, and heavy to edit by hand.

gettext PO (GNU gettext manual) brings decades of tooling. Its msgctxt field disambiguates identical source strings with different meanings, translator comments travel with each entry, and a fuzzy flag marks translations that may no longer be correct. It is line-oriented, so reviews read cleanly.

Fluent (Project Fluent) was designed for asymmetric localization: a translation can use grammatical variants the source language does not have, without the source needing to anticipate them. It has its own syntax and a smaller ecosystem, so the case for choosing it rests on that design.

The default position this article takes: pick the format your translation loop can round-trip losslessly, and compile to whatever your runtime loads fastest. A team translating in-house with developers in the loop can live happily in JSON. A team sending work to external translators through a translation platform may find XLIFF or PO saves more time than it costs. Format choice follows the translation loop, not fashion. Metadata that must travel with content across tools has a standard vocabulary too, the W3C Internationalization Tag Set, which some toolchains use to carry notes such as translate-or-not and localization instructions.

Source of truth and repo layout

Every catalog setup needs one explicitly designated authority. There are two workable models:

  • Repo-canonical: the catalogs in the repository are the truth. A translation platform syncs from the repo, translators work there, and completed translations come back as commits or pull requests.
  • Platform-canonical: the translation platform is the truth. The repository receives exports and never edits locale catalogs directly.

Both work. What corrupts catalogs is dual-write without a designated authority: a developer fixes a German typo directly in the repo while the platform still holds the old text, and the next sync silently reverts the fix, or keeps both and conflicts. Write down which side is canonical, and make the other side read-only in practice.

Repo layout follows the namespace design from the key-architecture article. Three common shapes:

  • Per-locale files per namespace: locales/de/checkout.json, locales/de/account.json. Small diffs, easy route-level splitting.
  • Locale trees mirroring the source tree: catalogs live next to the feature code that uses them. Good ownership, more files.
  • One file per locale: simple until the file has thousands of keys and every translation pull request touches it.

The source-language catalog is special. It is generated from the code by extraction, never hand-edited to drift out of sync with what the code actually uses. If a key exists in the English catalog but nowhere in the code, extraction removes it; if the code uses a key the catalog lacks, extraction adds it.

Catalog changes review like code. A translation pull request should read key by key, with the source and target visible, and a reviewer who can see which strings changed. Whether that is pleasant depends on the format, which is one more reason flat JSON and PO often feel better in review than deeply nested files or verbose XML.

The extraction round trip

The loop, end to end:

  1. Extract keys, source strings, and descriptions from the code.
  2. Diff against the current source catalog: which keys are new, which changed, which were removed.
  3. Hand off the delta to the translation loop, with context attached.
  4. Import completed translations back into the locale catalogs.
  5. Compile runtime catalogs from the interchange files.

Each step is a tool invocation, which means CI can run every one of them.

Here is the same unit in the two representations, to make the interchange point concrete. What the runtime loads:

json
{
  "cart.itemCount": "{count, plural, one {# item in your cart} other {# items in your cart}}"
}

What travels to and from translators:

xml
<unit id="cart.itemCount">
  <notes>
    <note category="description">Cart badge tooltip. count is a number.</note>
  </notes>
  <segment state="translated">
    <source>{count, plural, one {# item in your cart} other {# items in your cart}}</source>
    <target>{count, plural, one {# Artikel im Warenkorb} other {# Artikel im Warenkorb}}</target>
  </segment>
</unit>

Decide change semantics before they happen. When a source string is edited, the existing translations are either invalidated, meaning they must be retranslated, or flagged, meaning they keep rendering but go back for review. The corruption this loop exists to prevent is the third option, silent reuse: the English says "Free shipping over 50" after a policy change, and the German still says 30 because nobody marked it. Hashing the source text per key lets tooling detect this automatically; check whether your extraction tool does.

Deletion hygiene. Keys removed from code leave the source catalog immediately. Locale catalogs may keep them briefly, a grace period that protects a translation still in flight during a rollback, but then the unused-key gate removes them. This is the dead-key detection from the key-architecture article, made operational.

String freeze is the release-cycle tool on top: a window before a launch during which source strings stop changing, so every locale catalog can converge on a fixed target. It is a concept worth naming even for teams that never formalize it, because the alternative is chasing a moving source to the release date.

Machine translation, where a team uses it, sits inside the translation loop at step 3, not in the catalog layer. The files and gates in this article are the same whoever or whatever produces the target text.

CI gates that keep catalogs releasable

The gate set, each one mechanical and cheap to run:

  • Syntax validity per format: every file parses.
  • No missing keys against the source catalog, for every locale marked as a release locale.
  • No unused keys beyond the grace period.
  • Placeholder parity: every placeholder in the source message appears in each target, with the same name.
  • ICU syntax validity per message, checked against the ICU MessageFormat grammar, including a required other branch in every plural and select.
  • Completeness threshold per locale, measured and reported.

Placeholder parity is, in our view, the highest-value gate. A translated message that dropped {count}, renamed {name} to a translated word, or broke a brace may not fail anywhere until runtime unless a check catches it, and then only in that one locale, on the screen that uses it. No unit test in the source language will find it, and the developer who shipped the feature may not be able to read the locale where it breaks. A translation platform can flag some of this class before release too: Crowdin's QA checks, for example, include ICU syntax and placeholder mismatch checks. But a platform checks the translations that pass through it, while catalog CI can check every change to a catalog, whatever produced it.

Run the gates on every path a catalog can change, not only on developer pull requests. Translations imported from a platform, bulk exports, and hand fixes made during an incident all need the same checks, because a broken placeholder is just as fatal when it arrives through an automated sync. The simplest arrangement is that catalogs only ever enter the main branch through a pull request, whatever produced them, and the gate job runs on every such pull request.

The gates split into two kinds with different consequences. Broken means a syntax error, a placeholder mismatch, or an invalid ICU message: in any locale, that fails the build, because it can crash rendering. Incomplete means missing translations: that is a per-locale ship-or-hold decision against a completeness threshold, and the number feeds the locale-fallback article's coverage policy. Mixing the two, by failing builds on incompleteness or merely warning on broken placeholders, makes the gate either unbearable or useless.

The boundaries of this layer, restated: pseudo-localization as a rendering-level check belongs to the pseudo-localization article, runtime fallback behavior to the locale-fallback article, and catalog loading and splitting cost to the i18n-performance article. What this article supplies to all of them is catalogs that parse, match their source, and can be trusted in every locale that ships.

Project Inquiry