xlf-sync

February 3, 2026 ยท View on GitHub

npm version npm downloads github issues license PRs Welcome TypeScript CI

๐Ÿ“ Read the article: The Missing Piece in Angular i18n

The definitive CLI tool for synchronizing Angular XLIFF (1.2 & 2.0) locale files.

xlf-sync is a robust, production-ready utility designed to solve the persistent challenge of Angular i18n management: keeping your locale files (messages.<locale>.xlf) in perfect sync with your source file (messages.xlf), without data loss or corruption.

It is built to integrate seamlessly into professional workflows, supporting both local development and strict CI/CD pipelines.

xlf-sync

๐ŸŒ Visit the Official Landing Page & Documentation


๐Ÿš€ Why xlf-sync?

If you are coming from xliffmerge or ng-extract-i18n-merge, you'll find xlf-sync to be a modern, faster, and more reliable alternative.

Featurexlf-syncxliffmergeng-extract-i18n-merge
XLIFF 1.2 & 2.0โœ… Yesโœ… Yesโš ๏ธ Partial
Metadata Preservationโœ… Absoluteโš ๏ธ Limitedโš ๏ธ Limited
Visual Dashboardโœ… YesโŒ NoโŒ No
Zero Data Lossโœ… Guaranteedโš ๏ธ Riskyโœ… Yes
Active Maintenanceโœ… ActiveโŒ Legacyโœ… Active

Tip

Migration follows a similar flow: Simply point xlf-sync to your source and locale files. It will automatically detect your XLIFF version and merge without stripping your approved translations or translator notes.


โœจ Key Features

  • ๐Ÿ”„ Full Synchronization: Automatically adds missing keys from messages.xlf to all your locale files.
  • ๐Ÿง  Metadata Preservation: Preserves all notes, context groups, and custom attributes (e.g., approved="yes") during sync. Zero data loss.
  • ๐Ÿ›ก๏ธ Data Safety: Never overwrites existing translations. Your work is safe.
  • ๐Ÿงฌ Multi-Version Support: Seamlessly handles XLIFF 1.2 and 2.0 in the same project. It auto-detects the version per file.
  • ๐Ÿงน Auto-Sorting: Reorders translations in locale files to match the source file's order, ensuring clean and readable diffs.
  • ๐Ÿ’€ Graveyard Mode: Optionally moves obsolete keys to a separate "graveyard" file instead of deleting them, preserving historical work.
  • ๐Ÿค– CI/CD Ready: Dedicated check command with strict exit codes for your build pipelines.
  • โœจ Pretty Printing: Normalizes XML formatting across all files, eliminating "dirty" diffs from other tools.

๐Ÿ“ฆ Installation

Install globally or as a dev dependency in your project:

npm install -D xlf-sync
npx xlf-sync --help

๐ŸŽฎ How it looks

$ npx xlf-sync sync

  xlf-sync v1.3.7
  --------------------------------------------------
  โœ” messages.xlf parsed (142 keys)
  โœ” messages.el.xlf synced (+12 new, -3 obsolete)
  โœ” messages.de.xlf synced (+12 new, -3 obsolete)
  โœ” messages.fr.xlf synced (+12 new, -3 obsolete)
  --------------------------------------------------
  โœจ Done! Your locale files are in perfect sync.

๐Ÿ“‚ Configuration

xlf-sync CLI

You can avoid passing command-line arguments every time by creating an xlf-sync.json (or xlf-sync.config.json) file in your project root.

Example xlf-sync.json

{
  "source": "src/locale/messages.xlf",
  "locales": "src/locale/messages.*.xlf",
  "sync": {
    "newTarget": "todo",
    "obsolete": "mark",
    "dryRun": false
  },
  "check": {
    "failOnMissing": true,
    "verbose": true
  }
}

All Configuration Options

OptionJSON KeyTypeDescription
GlobalsourcestringPath to source messages.xlf
localesstringGlob for locale files
Syncsync.newTargetstringtodo | empty | source
sync.obsoletestringdelete | mark | graveyard
sync.graveyardFilestringPath pattern for graveyard files
sync.failOnMissingbooleanExit non-zero on missing targets
sync.dryRunbooleanDo not write files
Checkcheck.failOnMissingbooleanExit non-zero on missing targets
check.failOnObsoletebooleanExit non-zero on obsolete keys
check.failOnAddedbooleanExit non-zero on un-synced keys
check.newTargetstringtodo | empty | source (for diff only)
check.verbosebooleanPrint missing keys list

Tip

Precedence: Command Line Flags > xlf-sync.json > Default Values.


๐Ÿš€ Usage

1. The sync Command

The core command to update your locale files. It reads the source file and updates all target locale files found by the glob pattern.

# Basic usage
npx xlf-sync sync \
  --source src/locale/messages.xlf \
  --locales "src/locale/messages.*.xlf"

Sync Options

OptionDefaultDescription
--source <path>src/locale/messages.xlfPath to the source XLIFF file generated by ng extract-i18n.
--locales <glob>src/locale/messages.*.xlfGlob pattern to find your target locale files (e.g., src/locale/*.xlf).
--new-target <mode>todoStrategy for new keys:
โ€ข todo: Fills target with TODO.
โ€ข empty: Leaves target empty.
โ€ข source: Copies source text to target.
--obsolete <mode>markStrategy for removed source keys:
โ€ข mark: Keeps key with state="obsolete" (or prefix).
โ€ข delete: Permanently removes the key.
โ€ข graveyard: Moves key to a separate file (see below).
--graveyard-file <pattern>src/locale/_obsolete.{locale}.xlfPattern for the output "graveyard" file. Used only if --obsolete graveyard. {locale} is replaced dynamically.
--fail-on-missingfalseExits with error (code 1) if any keys are missing translations. Useful if you want to enforce 100% translation coverage during sync.
--dry-runfalseSimulates the operation without writing changes to disk.


2. The report Command

Generates a detailed console report about the translation coverage for each locale file. Useful for getting a quick overview of work remaining.

npx xlf-sync report --source src/locale/messages.xlf --locales "src/locale/messages.*.xlf"

Output Example:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Locale โ”‚ XLF โ”‚ Keys โ”‚ Translated โ”‚ Pending โ”‚ % Cov  โ”‚ Words โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ de     โ”‚ 2.0 โ”‚ 120  โ”‚ 115        โ”‚ 5       โ”‚ 95.8%  โ”‚ 432   โ”‚
โ”‚ fr     โ”‚ 2.0 โ”‚ 120  โ”‚ 40         โ”‚ 80      โ”‚ 33.3%  โ”‚ 150   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Report Options

OptionDefaultDescription
--source <path>src/locale/messages.xlfPath to the source XLIFF file.
--locales <glob>src/locale/messages.*.xlfGlob pattern for target locale files.

3. The dashboard Command

Generates a modern, standalone HTML dashboard to visualize your translation progress with beautiful charts, tables, and an interactive translation matrix.

npx xlf-sync dashboard --out report.html

xlf-sync Dashboard

Features:

  • ๐Ÿ“Š Visual Statistics Cards: Overview of locales, total keys, translated count, and pending translations
  • ๐Ÿ“ˆ Coverage Progress Bars: Per-locale translation progress with percentage indicators
  • ๐Ÿ” Translation Matrix: Interactive table showing which keys exist in each locale
    • โœ… Green checkmark for translated keys
    • โŒ Red X for missing translations
    • Search bar to filter by key ID
  • ๐ŸŽจ Modern UI: Built with Tailwind CSS and Alpine.js for a premium, responsive experience
  • ๐Ÿ“ฑ Mobile-Friendly: Fully responsive design that works on all devices

Dashboard Options

OptionDefaultDescription
--source <path>src/locale/messages.xlfPath to the source XLIFF file.
--locales <glob>src/locale/messages.*.xlfGlob pattern for target locale files.
--out <path>xlf-report.htmlPath where the HTML file will be saved.

4. The check Command

A read-only command designed for Continuous Integration (CI) pipelines. It verifies the state of your translations without modifying any files.

# Check if files are in sync
npx xlf-sync check --fail-on-missing

Check Options

OptionDefaultDescription
--source <path>src/locale/messages.xlfPath to the source XLIFF file.
--locales <glob>src/locale/messages.*.xlfGlob pattern for target locale files.
--verbosefalseLists exactly which keys are missing or obsolete for each locale.
--fail-on-missingfalseCI Failure Condition: Fail if any translation targets are missing or empty.
--fail-on-obsoletefalseCI Failure Condition: Fail if obsolete keys exist in locale files.
--fail-on-addedfalseCI Failure Condition: Fail if new keys exist in source that haven't been synced to locales yet.

๐Ÿ“š Advanced Workflows

Keeping Files Clean (Graveyard Mode)

For large, long-lived projects, we recommend the Graveyard Strategy. Instead of cluttering your main files with obsolete keys or deleting them immediately (and losing work), this mode moves them to a separate file.

npx xlf-sync sync --obsolete graveyard

Result:

  • messages.fr.xlf: Contains only active, valid translations.
  • _obsolete.fr.xlf: Contains all retired keys. You can restore them later if needed.

Standard CI/CD Pipeline

Add this step to your Pull Request validation workflow to ensure no developer merges broken translations:

- name: Verify i18n Sync
  run: npx xlf-sync check --fail-on-missing --fail-on-added --verbose

๐Ÿ› ๏ธ Supported Formats

FormatSupport Level
XLIFF 1.2Legacy Angular projects. Supported fully.
XLIFF 2.0Modern Angular default. Supported fully.
HybridMixed version projects are detecting and handled automatically per file.


๐Ÿค Contributing

We welcome contributions! Whether it's bug reports, feature requests, or code contributions, your help is appreciated.

Please read our Contributing Guidelines to get started.

Quick ways to contribute:

Buy Me A Coffee


๐Ÿ“„ License

MIT ยฉ Anastasios Theodosiou