In Loginet Platform you can localize your URLs and palce the translations in config files.
# config.yml
loginet_routing:
locales: [en, hu, de]
default_locale: hu
# routing.yml
loginet_demo:
resource: "@LoginetDemoBundle/Resources/config/routing.yml"
type: alternative
prefix: /
If you create a route with a resource
config and set its tope to alternative
, it will be parsed as alternative route.
# LoginetDemoBundle/Resources/config/routing.yml
loginet_demo_main:
path:
alternative_paths:
en: /registration
de: /registrierung
hu: /regisztracio
methods: [GET]
defaults: { _controller: LoginetDemoBundle:Registration:index }
<!-- LoginetDemoBundle/Resources/config/routing.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://xml.loginet.hu/platform/routing-1.0.xsd">
<route id="loginet_demo_main" path="">
<default key="_controller">LoginetDemoBundle:Registration:index</default>
<alternative_path locale="en" path="/registration" />
<alternative_path locale="de" path="/registrierung" />
<alternative_path locale="hu" path="/regisztracio" />
</route>
</routes>
This creates 3 routes:
Path | _locale |
---|---|
/regisztracio |
not given, because hu is the default locale |
/en/registration |
en |
/de/registrierung |
de |
You don't have to define paths for every locales, then defualt path will be used:
# LoginetDemoBundle/Resources/config/routing.yml
loginet_demo_main:
path: /registration
alternative_paths:
hu: /regisztracio
methods: [GET]
defaults: { _controller: LoginetDemoBundle:Registration:index }
<!-- LoginetDemoBundle/Resources/config/routing.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://xml.loginet.hu/platform/routing-1.0.xsd">
<route id="loginet_demo_main" path="registration">
<default key="_controller">LoginetDemoBundle:Registration:index</default>
<alternative_path locale="hu" path="/regisztracio" />
</route>
</routes>
Path | _locale |
---|---|
/regisztracio |
not given, because hu is the default locale |
/en/registration |
en |
/de/registration |
de |