I have created a route that translates url segments. This route can be
used for those web applications that needs url translated into
different languages. For example, en.domain.com can have urls
translated to english, while it.domain.com urls can be translated to
italian language.
How to use it:
Zend_Registry::set('Zend_Translate', new Zend_Translate('gettext', '/
path/to/translation', $lang));
$router->addRoute('article', new Zend_Controller_Router_Route_Translate(
'/;shop/;item/:id',
array(
'controller' => 'article',
'action' => 'view'
)));
Routing:
$lang = 'en' => /show/item/:id
$lang = 'it' => /negozio/articolo/:id
You can take a look at the class here:
http://download.pracucci.com/php/zf/Zend_Controller_Router_Route_Translate.php.txt
(it also supports lazy initialization)
May you give me a feedback?
Do you think it could be proposed to Zend, with some fixes and
modifications?
Thanks,
Marco Pracucci
没有评论:
发表评论