Symfony Translation

Symfony's internationalization engine — message catalogues, pluralization, and translation-file loaders/dumpers for multiple formats

Library
Composer
vv8.1.4
6,600stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity92
Maintenance96
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture80
Code Quality82
Innovation62
Learning Curve68

The Symfony Translation component provides everything needed to internationalize an application’s user-facing strings: a Translator that resolves message IDs against locale-specific catalogues, ICU-compliant pluralization rules, locale fallback chains, and loader/dumper pairs for a wide range of file formats (YAML, XLIFF, PO/MO, JSON, CSV, PHP arrays, and more). Catalogues can be built from static files or generated dynamically, and the component ships an Extractor that scans templates/code for translatable strings to keep catalogues in sync as an application grows.

Beyond the core translator, it includes developer-facing tooling — a DataCollector for the Symfony profiler showing which messages were and weren’t translated per request, a LocaleSwitcher for temporarily changing locale within a request, and a Provider abstraction for syncing catalogues with external translation management platforms (Loco, Lokalise, Crowdin).

What You Get

  • A Translator implementing locale resolution, fallback chains, and ICU MessageFormat pluralization
  • Loaders and dumpers for YAML, XLIFF, PO/MO (gettext), JSON, CSV, INI, and PHP-array catalogue formats
  • An Extractor that scans PHP/Twig templates for translatable strings to keep catalogues complete
  • Provider integrations for syncing translations with external TMS platforms like Loco, Lokalise, and Crowdin
  • A profiler DataCollector and console commands for auditing missing or unused translation keys

Common Use Cases

  • Serving a multi-language web application with locale-specific message catalogues and automatic fallback (e.g. fr_CA falling back to fr)
  • Extracting and syncing translatable strings with professional translators via a TMS provider integration instead of manual file editing
  • Handling pluralization correctly across languages with different plural rules using ICU MessageFormat syntax
  • Auditing a codebase for missing translations or orphaned catalogue keys before a release via the translation:lint/debug console commands

Under The Hood

Architecture Translator.php implements TranslatorInterface, holding a set of MessageCatalogueInterface instances (one per locale, under Catalogue/) populated by format-specific Loader/ classes; Formatter/ applies ICU MessageFormat rules for pluralization, Extractor/ statically scans source files to discover translatable strings, and Provider/ implementations handle bidirectional sync with external translation-management APIs.

Tech Stack PHP 8.4+ core requiring only symfony/polyfill-mbstring and symfony/translation-contracts; optional dev/runtime integrations include symfony/console (for CLI commands), symfony/http-client-contracts (for provider sync), nikic/php-parser (for accurate PHP string extraction), and symfony/config/dependency-injection for framework wiring.

Code Quality A comprehensive Tests/ tree covers each loader/dumper format, the ICU pluralization formatter, and provider integrations individually; the component’s very active maintenance (82/100 health, ~9.7 commits/month) and 100+ tagged releases reflect long-term investment from the Symfony core team given translation is a foundational cross-cutting concern.

API Design The basic trans() API is simple and well-documented with a quick-start example in the README, but the full surface — catalogues, extractors, providers, pluralization rule syntax — takes longer to master than a narrowly scoped component, a fair trade-off for the breadth of formats and workflows it supports.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search