I should set up a router with dynamic translation for a better SEO
I ended up with this code
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
//$this->_layout =
Zend_Controller_Action_HelperBroker::getStaticHelper('Layout');
// $this->_view = $this->_layout->getView();
try{
$i18n = Zend_Registry::get('i18n');
$locale = $i18n['locale'];
$lang = $i18n['lang'];
}
catch(Zend_Exception $e){
$locale = self::DEFAULT_LOCAL;
$lang = self::DEFAULT_LANG;
}
$zl = new Zend_Locale();
$zl->setLocale($locale);
Zend_Registry::set('Zend_Locale', $zl);
$fileName = APPLICATION_PATH . '/configs/lang/'. $lang . '.php';
if(!file_exists($fileName)){
$fileName = APPLICATION_PATH . '/configs/lang/'.
self::DEFAULT_LANG . '.php';
}
if(strpos($lang, '_') !== false){
list($lang,$region)= explode('_',$lang);
}
$translate = new Zend_Translate('array', $fileName , $lang);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Form::setDefaultTranslator($translate);
$route = new Zend_Controller_Router_Route(
':module/:@controller/:@action/*',
array(
'module'=>'default',
'controller' => 'index',
'action' => 'index'
)
);
$this->_router->addRoute('default', $route);
}
it works with
en
default/live/write
it
default/dalvivo/scrivi
en
admin/login
it
admin/logati
but it doesn't work with
en
live/write
it
dalvivo/scrivi
even if I have
'module'=>'default'
Can you help me please ?
Bye.
Whisher
--
View this message in context: http://n4.nabble.com/i18n-Router-Translate-how-to-avoid-default-in-the-url-tp956296p956296.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论