dev-master
9999999-dev http://albertofem.comJpnForPhp Symfony2 bundle integration
MIT
The Requires
The Development Requires
bundle route symfony translatable path
JpnForPhp Symfony2 bundle integration
Allows using translations in routes paths:, (*2)
/** * @Route("/[my.translatable.key]/route/{param}", options={"translatable"=true}) */ public function myAction() { }
If my.transatable.key
is defined in English as: my_translatable_route
, this will produce a route:, (*3)
/my_translatable_route/route/whatever_param
Require it in composer:, (*4)
composer require albertofem/translatableroutepath-bundle dev-master
Install it:, (*5)
composer update albertofem/translatableroutepath-bundle
Add it to your bundles:, (*6)
$bundles = array( ..., new \AFM\Bundle\TranslatableRoutePathBundle\AFMTranslatableRoutePathBundle() );
Additionally, you can use this bundle with JMSI18nRoutingBundle
in which case you will need to register it before this one:, (*7)
$bundles = array( ... new \JMS\I18nRoutingBundle\JMSI18nRoutingBundle(), new \AFM\Bundle\TranslatableRoutePathBundle\AFMTranslatableRoutePathBundle() );
If you need to run the tests:, (*8)
./vendor/bin/phpunit
You need to add the option to your route to be translatable:, (*9)
/** * @Route("/[my.translatable.key]/route/{param}", options={"translatable"=true}) */ public function myAction() { }
Using YAML:, (*10)
my_translatable_route: path: /[my.translatable.key]/route/{param} options: { translatable: true }
Use the syntax [...]
to referer to translations in your routes paths. You can use this syntax in annotations/yaml/PHP indistintively., (*11)
If your are using this great bundle, routes will be automatically translated to all the locales set in the configuration., (*12)
When using Symfony core router, all routes are translated into the default locale. If you need a Route to be translated in another language, you must specify the _locale
default parameter:, (*13)
my_translatable_route: path: /[my.translatable.key]/route/{param} options: { translatable: true } defaults: { _locale: en } # this route will translated in English
JpnForPhp Symfony2 bundle integration
MIT
bundle route symfony translatable path