8000 Internationalized routing fallback locale · Issue #27938 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Internationalized routing fallback locale #27938
Closed
@XWB

Description

@XWB

Description
Unless I'm overlooking something, the internationalized routing as introduced in Symfony 4.1 has no fallback locale. We use 5 different locales within our application: nl_NL, nl_BE, en_GB, en_US and de_DE. We use a custom event listener to set the _locale value in the request. So we only use "full" locales, and not "nl", "en" etc.

For the Translator component, nl_NL and nl_BE automatically fall back to translations/messages.nl.yml while en_GB and en_US fall back to translations/messages.en.yml. This allows us to avoid duplicate translations.

The JMSI18nRoutingBundle has a similar approach as route translations are put in translations/routes.en.yml and translations/routes.nl.yml. As such we don't have to create duplicate translations files for en_GB and en_US.

As we try to migrate JMSI18nRoutingBundle to Symfony internationalized routing, we would like to have a similar approach (i.e. avoid duplicate translations). Right now, we have to configure routes like this:

news:
    controller: App\Controller\NewsController::item
    path:
        nl_BE: /nieuws
        nl_NL: /nieuws
        en_GB: /news
        en_US: /news
        de_DE: /nachrichten

As you can see, that's a lot of duplication. It would be nice if the Routing component could look for fallback locales, similar like the Translation component and JMSI18nRoutingBundle. In the example below, nl_NL and nl_BE would also match the nl path.

news:
    controller: App\Controller\NewsController::item
    path:
        nl: /nieuws
        en: /news
        de: /nachrichten

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0