Zend Translate 找不到语言
我遇到了 Zend Translate 问题。我已经在引导程序中配置了 zend 翻译,如下所示
public function _initTranslate() {
$locale = new Zend_Locale();
Zend_Registry::set('Zend_Locale', $locale);
$translate = new Zend_Translate(array(
'adapter' => 'ini'
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . '/configs/languages/pt.ini',
'locale' => 'pt'
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . '/configs/languages/en.ini',
'locale' => 'en'
)
);
$translate->setLocale($locale);
Zend_Registry::set('Zend_Translate', $translate);
}
,我添加了语言,在我看来,我使用了翻译助手,但它显示了我
Notice: The language 'en' has to be added before it can be used.
in C:\xampp\ZendFramework-1.11.10\library\Zend\Translate\Adapter.php
on line 443
Notice: No translation for the language 'en' available.
in C:\xampp\ZendFramework-1.11.10\library\Zend\Translate\Adapter.php
on line 456
遵循 zendframework 参考指南的以下错误。我做错了什么?
I've got a Zend Translate Issue. I have configure the zend translate in the bootstrap like below
public function _initTranslate() {
$locale = new Zend_Locale();
Zend_Registry::set('Zend_Locale', $locale);
$translate = new Zend_Translate(array(
'adapter' => 'ini'
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . '/configs/languages/pt.ini',
'locale' => 'pt'
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . '/configs/languages/en.ini',
'locale' => 'en'
)
);
$translate->setLocale($locale);
Zend_Registry::set('Zend_Translate', $translate);
}
I've added the languages and in my views I used translate helper but it shows me the following erros
Notice: The language 'en' has to be added before it can be used.
in C:\xampp\ZendFramework-1.11.10\library\Zend\Translate\Adapter.php
on line 443
Notice: No translation for the language 'en' available.
in C:\xampp\ZendFramework-1.11.10\library\Zend\Translate\Adapter.php
on line 456
I've followed zendframework reference guide. What I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您是否尝试将语言传递给
Zend_Locale
?此外,我找到了解决方法:
请参阅 http://framework.zend.com/issues/浏览/ZF-6612了解更多详情。注意:这是 1.8 的错误,我看到您正在使用 1.10,但解决方法可能仍然有效。
这也是一个很好的帖子: http:// zend-framework-community.634137.n4.nabble.com/how-handle-Locale-td659923.html
另外,
Zend_Translate
提供了一个专门针对该类禁用通知的选项。如果内容正在被翻译,那么这(根据Zend)不是“错误”并且应该禁用通知。Did you try passing a language to
Zend_Locale
?Additionally, I found a work around:
See http://framework.zend.com/issues/browse/ZF-6612 for more details. Note: this is a bug for 1.8, I see you're using 1.10 but the work-around might still work.
This is also a good thread: http://zend-framework-community.634137.n4.nabble.com/how-handle-Locale-td659923.html
Also,
Zend_Translate
offers an option to disable notices specifically for that class. If the content is being translated, then this (according to Zend) is not an "error" and notices should be disabled.我用下面的代码解决了这个问题:
我编写了一个插件,通过传递 GET 变量来在运行时更改语言 例如:&lang=en
I solved ths issue with the code below:
And I coded a plugin to change language at runtime by just passing a GET variable Ex.: &lang=en
逐步说明
为什么不尝试使用 Poedit 进行本地化..顺便说一句,它是一个很棒的工具..这是您引导程序中的
... /***结束引导程序代码*/
/插件文件*保存在你的插件目录中*/
/*****用于翻译的库文件****< /em>**/
最后在你的应用程序中你可以调用 Application_Locale::translate('your string') 进行翻译
最重要的是,请阅读本文来为您的应用程序设置 poedit
http://techie.ayyappadas.com/how-do-use-poeditor
Why dont you try Poedit for Localization ..BTW its a great tool..here's the step by step way
IN your bootstrap...
/***End of code for bootstrap*/
/Plugin file* save in your plugins directory*/
/*****A library file for translation******/
And finally in your application you can call Application_Locale::translate('your string') for translation
And most importanty read this for setting up poedit for your application
http://techie.ayyappadas.com/how-do-use-poeditor
正如我在我的应用程序中所表达的,当您将不完整的数组传递给 Zend_Translate 时,会发生以下通知
您应该添加 en 并在其中添加一些参数,例如:
As i expressed in my app, Following notice happen when you pass incomplete array to Zend_Translate
You should add en with some parameter in it like :
查看
Project_dir/resources/languages
是否有可用的en
文件夹?如果没有,请查看可用语言文件夹并在其中创建Zend_Validate.php
文件以获取英语验证错误消息。Look into
Project_dir/resources/languages
is there anen
folder available? If not please look in available language folder and createZend_Validate.php
file there for English validation error messages.