Alternative Router

In Loginet Platform you can localize your URLs and palce the translations in config files.

Setup

# config.yml
loginet_routing:
    locales: [en, hu, de]
    default_locale: hu

Alternative Route resource

# 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.

The route config with alternative paths

YAML

# LoginetDemoBundle/Resources/config/routing.yml
loginet_demo_main:
    path: 
    alternative_paths:
        en: /registration
        de: /registrierung
        hu: /regisztracio
    methods: [GET]
    defaults: { _controller: LoginetDemoBundle:Registration:index }

XML

<!-- 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

Default path

You don't have to define paths for every locales, then defualt path will be used:

YAML

# LoginetDemoBundle/Resources/config/routing.yml
loginet_demo_main:
    path: /registration
    alternative_paths:
        hu: /regisztracio
    methods: [GET]
    defaults: { _controller: LoginetDemoBundle:Registration:index }

XML

<!-- 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