views:

314

answers:

1

I have a Zend Framework site that setups all routes in a file, routes.ini. The routes look like this:

routes.popular.route = popular/:type/:page/:sortOrder
routes.popular.defaults.controller = popular
routes.popular.defaults.action = index
routes.popular.defaults.type = images
routes.popular.defaults.sortOrder = alltime
routes.popular.defaults.page = 1
routes.popular.reqs.type = \w+
routes.popular.reqs.page = \d+
routes.popular.reqs.sortOrder = \w+

In bootstrap.php they are read and added to the frontController:

$config = new Zend_Config_Ini(APPLICATION_PATH . ‘/config/routes.ini’);
$router = $frontController->getRouter();
$router->addConfig($config,‘routes’);

I would like to add localization to the URL, for example www.mysite.com/en/popular, www.mysite.com/sv/popular. What is the preferred way of doing this?

+1  A: 

It's a good idea to have the default route localized, so I would suggest the following configuration:

routes.default.route = :lang/:controller/:action
routes.default.defaults.lang = en
routes.default.defaults.controller = default
routes.default.defaults.action = index

routes.popular.route = :lang/popular/:type/:page/:sortOrder
routes.popular.defaults.lang = en
routes.popular.defaults.controller = popular
routes.popular.defaults.action = index
routes.popular.defaults.type = images
routes.popular.defaults.sortOrder = alltime
routes.popular.defaults.page = 1
routes.popular.reqs.type = \w+
routes.popular.reqs.page = \d+
routes.popular.reqs.sortOrder = \w+
St.Woland
Would not this lead to that I would have to define the default language for each route? Is there a way to set a global default language?
Peter Moberg