Bakerversity
Module 4: Respecting the Reader's Time & EyesLesson 4 of 8

Lesson 4.2: Localization Interchange Standards (XLIFF & PO)

Understand how XLIFF and PO files isolate human text from code architecture.

1. Human Impact & Context

Handing raw source code assets (like React .jsx components, Android .xml trees, or C++ source files) directly to translators is one of the fastest ways to break a release build. A translator might inadvertently translate a code key, delete an XML tag attribute, or break a syntax boundary.

To protect source code while providing translators with essential context (such as translation memory matches, character limits, and status states), localization pipelines use Interchange Standards.

  ┌──────────────────┐         ┌──────────────────────────┐         ┌──────────────────┐
  │  Development     │  Extract│  Interchange Standards   │ Translate│  CAT Tools &     │
  │  Source Assets   ├────────►│  (XLIFF / Gettext PO)    ├────────►│  TMS Platforms   │
  │  (JSON, XML, UI) │         │  • Source & Target tags  │         │  • Linguist UI   │
  └────────┬─────────┘         │  • Inline code isolation │         └────────┬─────────┘
           ▲                   │  • Translation States    │                  │
           │                   └────────────┬─────────────┘                  │
           │                                │                                │
           └────────────────────────────────┴────────────────────────────────┘
                             Merge Back clean target code

By extracting human-translatable text out of code and encapsulating it into XLIFF (XML Localisation Interchange File Format) or Gettext PO (Portable Object) files, localization engineers achieve three critical objectives:

  1. Safety: Raw code logic and file structures remain untouchable in the repository.

  2. Context & Metadata: Translators receive inline notes, state indicators (translated, needs-review), and exact character length restrictions.

  3. Interoperability: Linguists can open files in any Computer-Assisted Translation (CAT) tool or Translation Management System (TMS) without installing development environments.

2. Core Mechanics & Technical Concepts

1. XLIFF (XML Localisation Interchange File Format)

XLIFF is an OASIS open standard based on XML, used globally across enterprise localization tools, Apple Xcode export workflows, and major TMS platforms.

Core Structure (<file>, <unit>, <segment>, <source>, <target>)

XML

xml
<?xml version="1.0" encoding="UTF-8"?> <xliff version="2.0" xmlns="urn:oasis:names:tc:xliff:document:2.0" srcLang="en" trgLang="ja"> <file id="f1" original="src/components/Header.json"> <unit id="u_welcome"> <notes> <note priority="1">Greeting banner shown on initial login dashboard.</note> </notes> <segment state="translated"> <source>Welcome back, <ph id="0" dataRef="d1"/>!</source> <target>おかえりなさい、<ph id="0" dataRef="d1"/>様!</target> </segment> </unit> </file> </xliff>
  • <source> vs. <target>: Holds the original language text side-by-side with the localized translation payload.

  • Inline Placeholders (<ph>, <code>): Code variables (like {username} or <b>) are encapsulated inside protected placeholder tags (<ph id="0"/>) so translators cannot alter backend variable tokens.

  • Segment States (state="..."): Tracks workflow progression (initial, translated, reviewed, final).

2. GNU Gettext PO (Portable Object)

Originating in the open-source UNIX ecosystem, Gettext PO files are widely used in C/C++, Python, PHP, WordPress, and Linux software localization.

Structure (msgid, msgstr, msgctxt, # comments)

Code snippet

# Developer comment explaining UI context
#. Location: Login Screen / Header
#: src/components/Header.c:45
msgctxt "header_greeting"
msgid "Welcome back, %s!"
msgstr "おかえりなさい、%s様!"

# Plural syntax handling in PO files
msgid "One file deleted."
msgid_plural "%d files deleted."
msgstr[0] "%d plik został usunięty."
msgstr[1] "%d pliki zostały usunięte."
msgstr[2] "%d plików zostało usuniętych."
  • msgid: The source string (acts as both source text and default key).

  • msgstr: The localized target translation payload.

  • msgctxt (Message Context): Disambiguates identical source words with different meanings (e.g., "File" as a noun vs. "File" as a verb).

  • msgstr[N]: Handles plural forms dynamically based on target language header rules.

3. Real-World Industry Comparison

Feature

XLIFF (.xliff / .xlf)

Gettext PO (.po)

Underlying Standard

XML (OASIS Standard).

Plain-text Key/Value format.

Primary Ecosystems

Apple iOS/macOS (Xcode), Enterprise TMS platforms, Android exporters.

Linux, WordPress, C/C++, Python, PHP, Open-Source projects.

Disambiguation Method

<unit id="..."> and <notes> tags.

msgctxt (Context block).

Inline Code Protection

Native XML tags (<ph>, pc, sc, ec).

Plain text syntax escaping.

Plural Mechanism

ICU MessageFormat strings inside <source>/<target>.

nplurals header formula + indexed msgstr[N] array.

4. Cross-Platform Execution (Validating XLIFF & PO in VS Code)

  1. Syntax Highlighting: Install dedicated VS Code extensions (e.g., Gettext support or XLIFF Sync) to enable linter syntax highlighting for .po and .xliff files.

  2. Inspecting Tags in Split View: Use Split Editor (Cmd + \ / Ctrl + \) to inspect source code alongside generated interchange files.

  3. Validating Segment States: Ensure all <segment> tags in XLIFF files contain valid state attributes (state="translated" or state="final") before attempting automated merge scripts back into primary code repositories.

5. Next Steps & Lab Practice

Now that you understand how XLIFF and PO files isolate human text from code architecture, you are ready to manipulate and validate interchange payloads.

Proceed to 🛠️ Hands-On Lab 4.2: XLIFF Transformation & PO File Parsing, or create a quick knowledge check!

Ready to move on?

Mark this lesson complete when you’re ready.

→ Sign in to track your progress