ZF-3097: Create new route for multilanguage sites


An oft-used URL pattern for multi-lingual sites is to use the form '/:lang/...'. Currently, however, this is a difficult routing schema to achieve if you want to leave the flexibility to create a conventional modular site.

The suggestion is to create a route that extends the current Module route, and which takes an argument of a default language to use:

$router->addRoute('default', new Zend_Controller_Router_Route_Multilingual('de')); // default language is German

This would give such routes first-class support in the ZF MVC.


Postponing to 1.7.0; Martel and DASPRiD are working on a solution, part of which is included in 1.6, but the rest of which will happen for 1.7.0. At that time, we can easily add language-based routes.

I'm only responsible for the config- and hostname-part. Martel is the maintainer of the actual partial path chaining. As he is currently quite busy, I don't think that partial path chaining will make it into 1.7. Even 1.8 isn't really clear.

Assigning to Ben; this is addressed with chained routes in 1.7.0, IIRC.

Partial path route implemented in 1.8.

Can anybody of the participants explain, how to solve the requirements of a default multilanguage route? I can't see an solution using chained routes.

You simply take a standard route ":language", and all your other routes. Then you say for example

$languageRoute = new Zend_Controller_Router_Route(':language', array('language' => 'de');
$blogRoute = new Zend_Controller_Router_Route_Static('blog');
$blogRoute = $languageRoute->chain($blogRoute);

For more examples, see documentation or ask in #zftalk on