schmittjoh/JMSI18nRoutingBundle — Issue #25: multiple hosts, shared url due to en_UK and en_US
Author: fritsjanb
Created: 2012-03-05 11:40:08+00:00
State: open

For my current project I need separate hosts for en_UK and en_US, while most urls are still the same.

Thus, \/\ and \/\, with both \ the same.

Apart from this, I'd also prefer to NOT duplicate the translations (so not an en_US_news_overview and en_UK_news_overview when both translate to the same). This is currently not supported at all.

I'd like to propose the following. When routes are added to the routing collection a fall-back translation system could be used. First try to use the translation of \_route. If this one is not available, use \_route instead.

For locale en_UK: If the translation of en_UK_news_overview exists, add the route 'en_UK_news_overview: \', and the same for en_US. If the translation of en_UK_news_overview is not available, check for the translation of en_news_overview. If this one does exists, add the route 'en_UK_news_overview: \'. This way there are still different routing entries for en_UK and en_US, while the translation can be shared.

This comes with a single small issue: when two routes share the same url, the match() cannot distinguish between the two routes (/\ is only matched to the first (or is it to the last?) match). This can easily be fixed: take for example locales en_US and en_UK, with
```
en_UK_news_overview: /news
en_US_news_overview: /news
```

Assume we are on host en_UK, but the matcher finds the routing for the host corresponding en_US. We can now check if there exists an en_UK route (just replace the en_US part of en_US_news_overview with en_UK and generate the url). If this url is the same as the active url than there is no need to redirect to the other host, allowing multiple hosts to share urls. This change is even compatible with the current system.

A last feature I require is the following. Currently, when the url is not available for the active host a redirect is used.
Instead of redirecting to the other host I'd want a RouteNotFoundException to be thrown. This could be a configurable option: 'redirect_to_host' with standard value true, again BC.

Have you got any concerns regarding this approach, or any tips / advice?
I'll make a PR for this as soon as I can (probably this Thursday)