sokil / locale-bundle
Localization and internationalization in Symfony app
0.2
2017-05-05 21:30 UTC
Requires
- php: ^5.5 || ^7.0
- sokil/php-isocodes: ^1.0.1
Requires (Dev)
- phpunit/phpunit: >=3.7.38 <6.0
- satooshi/php-coveralls: >=0.7.1 <2.0
- symfony/framework-bundle: 2.* || 3.*
README
Installation
composer.phar require sokil/locale-bundle
Configure next parameters in ./app/config/config.yml
:
locale: query_parameter: lang cookie_parameter: lang path_parameter: false locales: # mapping of languages to locales uk: uk_UA.utf8 en: en_US.utf8
Current language resolving
Servise locale.preferred_language_listener
used to set current language from cookie, request URL or Accept-Language
request header. It enabled by default, if bundle registered.
Switch languages
Action setAction
from controller Sokil\LocaleBundle\Controller\LangController
used to set current lang.
Locales provider
Service locale.supported_locales_provider
used to get list of all supported languages with localised names of language.
To access locales provider from twig template, add global twig variable in ./app/config/config.yaml
:
twig: globals: locales_provider: "@locale.supported_locales_provider"