zend Translation 加入多种文件语言
我正在尝试将 zend 表单错误语言文件添加到我的语言文件中,可以在 中找到该文件,
ZendFramework-1.11.2.zip\ZendFramework-1.11.2\resources\languages
以便本地化表单验证器错误。此博客 http://www. thomasweidner.com/flatpress/2010/03/25/working-with-multiple-translation-sources/comments/ 解释了我尝试做的事情,但它失败了:(它只从我的 .ini 文件翻译, .php 不包括在内 这就是我所做的:
这是我的 application.ini
resources.translate.adapter = "ini"
resources.translate.default.locale = "it_IT"
resources.translate.default.locale = "en_US"
resources.translate.default.file = APPLICATION_PATH "/lang/source-it.ini"
resources.translate.translation.en = APPLICATION_PATH "/lang/source-en.ini"
;resources.translate.data.directory = APPLICATION_PATH "/lang"
resources.translate.data = APPLICATION_PATH "/lang"
然后我有这个
<?php
class Gestionale_Application_Resource_Translate extends Zend_Application_Resource_ResourceAbstract
{
public function init ()
{
$options = $this->getOptions();
$adapter = $options['adapter'];
$defaultTranslation = $options['default']['file'];
$defaultLocale = $options['default']['locale'];
$translate = new Zend_Translate($adapter, $defaultTranslation, $defaultLocale);
$translation_addme = new Zend_Translate(
'array',
APPLICATION_PATH."/resources/languages/it/Zend_Validate.php"
'it',
array('scan' => Zend_Translate::LOCALE_DIRECTORY)
);
$translate->addTranslation($translation_addme);
foreach ($options['translation'] as $locale => $translation) {
$translate->addTranslation($translation, $locale);
}
Zend_Registry::set('Zend_Translate', $translate);
return $translate;
}
}
,这是我的目录
c:\www\www\gestionale\application>dir /w /aD
Il volume nell'unità C è OS
Numero di serie del volume: 6A5E-FD9B
Directory di c:\www\www\gestionale\application
[.] [..] [.svn] [configs] [controllers]
[forms] [lang] [layouts] [models] [resources]
[views]
0 File 0 byte
11 Directory 447.780.282.368 byte disponibili
i am trying to add to my language file, the zend form errors language file, which can be found in
ZendFramework-1.11.2.zip\ZendFramework-1.11.2\resources\languages
in order to have localized form validators erorrs. This blog http://www.thomasweidner.com/flatpress/2010/03/25/working-with-multiple-translation-sources/comments/ explains what i try to do, but it fails :( it only translates from my .ini file, the .php is not included
Here is what i did:
this is my application.ini
resources.translate.adapter = "ini"
resources.translate.default.locale = "it_IT"
resources.translate.default.locale = "en_US"
resources.translate.default.file = APPLICATION_PATH "/lang/source-it.ini"
resources.translate.translation.en = APPLICATION_PATH "/lang/source-en.ini"
;resources.translate.data.directory = APPLICATION_PATH "/lang"
resources.translate.data = APPLICATION_PATH "/lang"
and then i have this
<?php
class Gestionale_Application_Resource_Translate extends Zend_Application_Resource_ResourceAbstract
{
public function init ()
{
$options = $this->getOptions();
$adapter = $options['adapter'];
$defaultTranslation = $options['default']['file'];
$defaultLocale = $options['default']['locale'];
$translate = new Zend_Translate($adapter, $defaultTranslation, $defaultLocale);
$translation_addme = new Zend_Translate(
'array',
APPLICATION_PATH."/resources/languages/it/Zend_Validate.php"
'it',
array('scan' => Zend_Translate::LOCALE_DIRECTORY)
);
$translate->addTranslation($translation_addme);
foreach ($options['translation'] as $locale => $translation) {
$translate->addTranslation($translation, $locale);
}
Zend_Registry::set('Zend_Translate', $translate);
return $translate;
}
}
and this is my dir
c:\www\www\gestionale\application>dir /w /aD
Il volume nell'unità C è OS
Numero di serie del volume: 6A5E-FD9B
Directory di c:\www\www\gestionale\application
[.] [..] [.svn] [configs] [controllers]
[forms] [lang] [layouts] [models] [resources]
[views]
0 File 0 byte
11 Directory 447.780.282.368 byte disponibili
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅通过查看您的代码我无法告诉您太多信息。我怀疑您的问题可能是因为您创建了自己的资源插件,这对于此目的来说是不必要的,某些东西没有正确引导,或者与您的 application.ini 存在一些冲突。无论如何,我会发布我的翻译设置,也许它会给你一些线索。
application.ini
这里没有关于翻译或语言环境的内容,因为我在 Bootstrap.php 中设置了它们。
Bootstrap.php
Just by looking at your code I cannot tell you much. I suspect that your problems might be because you create your own resource plugin, which is unnessesry for this purpose, somethings are not being bootstrap properly, or there are some conflicts with your application.ini. Any way, I will post my translation setup and maybe it will give you some clues.
application.ini
Nothing here about translation or locale since I setup them in Bootstrap.php.
Bootstrap.php