You don't have to put lang parameter into navigation. If the current route defined by you (request contains lang parameter) then you can simple use url view helper or directly the router's assemble method. I have created a controller plugin whick automatically adds chained routes to the router so if I create a new route (whick doesn't contain lang param) in bootstrap then later (if lang param is in url) the generated urls will contain the lang parameter. You can find it here: https://github.com/szjani/equcms/blo...n/Language.php
To use localized parameters in url depends on language parameter is not easy. You have to put locale information into translate object in the routing process. I think you should extends the Zend_Controller_Router_Route class and in match($request) method after locale is defined put it into the router's translate object. I used it with hostname route (url doesn't contain lang param, language depends on hostname):
class Szj_Controller_Router_HostnameRoute extends Zend_Controller_Router_Route_Hostname {
public static function getInstance(Zend_Config $config) {
$reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
$defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
$scheme = (isset($config->scheme)) ? $config->scheme : null;
return new self($config->route, $defs, $reqs, $scheme);
}
public function match($request) {
$res = parent::match($request);
if ($res) {
$locale = new Zend_Locale($this->getDefault('lang'));
Zend_Registry::set('Zend_Locale', $locale);
Zend_Registry::get('Zend_Translate')->setLocale($locale);
Zend_Registry::get('Zend_Translate_Url')->setLocale($locale);
Zend_Controller_Router_Route::setDefaultLocale($lo cale);
}
return $res;
}
}


LinkBack URL
About LinkBacks



Reply With Quote
