Hola buenas estoy intentando hacer una pagina con multilenguaje.
He visto este video tutorial:
http://www.zendcasts.com/introducing-zend_translate/2009/11/
Pero me surgen varios problemas.
El tranlaste no funciona, y cuando cambio del default controller me da error.
Zend_Controller_Router_Exception: No route matched the request
En el bootstrapt lo configure como el manual:
Código PHP:
protected function _initRouting()
{
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->removeDefaultRoutes();
//$router->setGlobalParam('langmodulecontrolleraction','en');
$router->addRoute('langmodulecontrolleraction',new Zend_Controller_Router_Route(
'/:lang/:module/:controller/:action',array('lang'=>':lang')));
$router->addRoute('langindex',new Zend_Controller_Router_Route(
'/:lang',
array('lang'=>'en',
'module'=>'default',
'controller'=>'home',
'action'=>'index')));
}
El .ini esta:
Código:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultControllerName = "home"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "default"
;; ROUTERS DEFAULT
resources.router.routes.home.route = "/:la/home/:id"
resources.router.routes.home.defaults.module = "default"
resources.router.routes.home.defaults.controller = "home"
resources.router.routes.home.defaults.action = "index"
resources.router.routes.contact.route = "/:la/contact/:who"
resources.router.routes.contact.defaults.module = "default"
resources.router.routes.contact.defaults.controller = "contact"
resources.router.routes.contact.defaults.action = "index"
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
autoloaderNamespaces[] = "ZendX"
autoloaderNamespaces[] = "Form_"
autoloaderNamespaces[] = "App_"
;; RESOURCE Plugings
resources.frontController.plugins.Multilanguage = App_Controller_Plugin_Multilanguage
Y mi plugin esta asi:
Código PHP:
class App_Controller_Plugin_Multilanguage extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// parent::preDispatch($request);
$lang = $request->getParam('lang','');
if($lang !='en' && $lang!='es')
{
$request->setParam('lang', 'en');
}
$lang = $request->getParam('lang');
if($lang =='en'){
$locate = 'en_En';
}
else{
$locale = 'es_ES';
}
$zl = new Zend_Locale();
$zl->setLocale($zl);
Zend_Registry::set('locale',$zl);
$translate = new Zend_Translate('csv',APPLICATION_PATH . '/configs/languages/'. $lang .'.csv',$lang);
var_dump($translate);
Zend_Registry::set('translate',$translate);
}
}
En la vista sale el var_dump del publig.
Correctamente es decir :
Con la url :http://www.test.com/en
array(1) { ["en"]=> array(1) { ["Home"]=> array(2) { [0]=> string(4) "Home"
Con la url :http://www.test.com/es
array(1) { ["en"]=> array(1) { ["Home"]=> array(2) { [0]=> string(4) "Hogar"
Parece ser que si esta cogiendo los archivos csv pero no lo traduce.
Muchas gracias