Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework Zend框架和切换视图脚本路径_Zend Framework_View_Translate - Fatal编程技术网

Zend framework Zend框架和切换视图脚本路径

Zend framework Zend框架和切换视图脚本路径,zend-framework,view,translate,Zend Framework,View,Translate,我有个问题。基本上,根据用户是否访问我们网站上的/es或/br或/cn等,我们有不同的语言模板文件。到目前为止,我们使用了一个定制的模板引擎来实现这一点,但是正在切换到ZF。如果语言变量为cn,我似乎不知道如何让ZF在say cn/about us中查找视图脚本 我不能(不想)使用Zend_Translate来实现这一点,因为我们有太多的翻译模板文件,而使用Zend_Translate来处理大量不同的文件,包括中文/韩文/日文段落是不可行的,我一时忘了我不会说这些语言 有人能帮我吗?您可以编写一

我有个问题。基本上,根据用户是否访问我们网站上的/es或/br或/cn等,我们有不同的语言模板文件。到目前为止,我们使用了一个定制的模板引擎来实现这一点,但是正在切换到ZF。如果语言变量为cn,我似乎不知道如何让ZF在say cn/about us中查找视图脚本

我不能(不想)使用Zend_Translate来实现这一点,因为我们有太多的翻译模板文件,而使用Zend_Translate来处理大量不同的文件,包括中文/韩文/日文段落是不可行的,我一时忘了我不会说这些语言


有人能帮我吗?

您可以编写一个控制器插件,并使用它的routeStartup()方法更改Zend_视图设置(视图脚本所在位置的路径),并在路由开始之前更改请求uri

class My_Controller_Plugin_LanguageSwitcher extends Zend_Controller_Plugin_Abstract
{
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        // examine the $_SERVER['REQUEST_URI'] and look for your language identifier
        // fetch the View and set appropriate view scripts path using setScriptPath() method
        // strip the language identifier from your REQUEST_URI
        // change the request uri using $request->setRequestUri('your-new-uri-without-the-language-  identifier');
    }
}