Symfony 7: I18n
- https://symfony.com/components/Translation
- How to Translate Messages using the ICU MessageFormat
Setup
composer require symfony/translation
composer require nikic/php-parser
Usage
# when creating new catalogue or installing a bundle that contains translations.
syc cache:clear
# lint
syc lint:yaml translations
# inspect
syc debug:translation hu --domain=messages+intl-icu
# show messages that should be translated
syc translation:extract --dump-messages hu
# update translation files with missing strings
syc translation:extract --format=yaml --force hu
Set locale from request
- Handling the User's Locale
-
Alternatively: set via routing: https://symfony.com/doc/current/translation.html#the-locale-and-the-url