Internationalization¶
Internationalization and localization adapt the applications and their contents
to the specific region or language of the users. In Symfony this is an opt-in
feature that needs to be installed before using it (composer require symfony/translation
).
Translation Source File Location¶
Best Practice
Store the translation files in the translations/
directory at the root
of your project.
Your translators' lives will be much easier if all the application translations are in one central location.
Translation Source File Format¶
The Symfony Translation component supports lots of different translation
formats: PHP, Qt, .po
, .mo
, JSON, CSV, INI, etc.
Best Practice
Use the XLIFF format for your translation files.
Of all the available translation formats, only XLIFF and gettext have broad support in the tools used by professional translators. And since it's based on XML, you can validate XLIFF file contents as you write them.
Symfony supports notes in XLIFF files, making them more user-friendly for translators. At the end, good translations are all about context, and these XLIFF notes allow you to define that context.
Tip
The PHP Translation Bundle includes advanced extractors that can read your project and automatically update the XLIFF files.