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

Skip to content

Internationalized routing fallback locale #27938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
XWB opened this issue Jul 13, 2018 · 0 comments
Closed

Internationalized routing fallback locale #27938

XWB opened this issue Jul 13, 2018 · 0 comments

Comments

@XWB
Copy link
Contributor
XWB commented Jul 13, 2018

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
symfony-splitter pushed a commit to symfony/routing that referenced this issue Aug 10, 2018
…nationalized routes (fancyweb)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Routing] Add fallback to cultureless locale for internationalized routes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#27938
| License       | MIT
| Doc PR        | symfony/symfony-docs#10108

Please check the related issue for the context.

TODO :
- [x] Update CHANGELOG
- [x] Update documentation

Commits
-------

fd2e3c36fb [Routing] Add fallback to cultureless locale for internationalized routes
nicolas-grekas added a commit that referenced this issue Aug 10, 2018
…nationalized routes (fancyweb)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Routing] Add fallback to cultureless locale for internationalized routes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27938
| License       | MIT
| Doc PR        | symfony/symfony-docs#10108

Please check the related issue for the context.

TODO :
- [x] Update CHANGELOG
- [x] Update documentation

Commits
-------

fd2e3c3 [Routing] Add fallback to cultureless locale for internationalized routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0