Zend Translate ini 适配器异常“Ini 文件‘数组’”未找到”
我从 Zend Translate 中得到一个丑陋的异常:
致命错误:未捕获的异常 'Zend_Translate_Exception' 并带有消息 'Ini file 'Array' not found' in C:\www\libraries\ZendFramework-1.10.5-minimal\library\Zend\Translate\ Adapter\Ini.php:54
application.ini
resources.translate.registry_key = "Zend_Translate"
resources.translate.adapter = "ini"
resources.translate.data.directory = APPLICATION_PATH“/语言”
resources.translate.options.scan = "目录"
resources.translate.locale = "en"
目录结构
application\languages\
应用程序\语言\en\component1.ini
应用程序\语言\en\component2.ini
应用程序\语言\el\component1.ini
application\languages\el\component2.ini
罪魁祸首 - Zend\Translate\Adapter\Ini.php
protected function _loadTranslationData($data, $locale, array $options = array()) {
$this->_data = array();
if (!file_exists($data)) {
require_once 'Zend/Translate/Exception.php';
throw new Zend_Translate_Exception("Ini file '".$data."' not found");
}
}
此时 var_dump($data) 返回 *
array(1) {
["directory"] =>string(45) "C:\www\projects\helloworld\application/languages"
}*
我做错了什么?
I get an ugly exception from Zend Translate:
Fatal error: Uncaught exception 'Zend_Translate_Exception' with message 'Ini file 'Array' not found' in C:\www\libraries\ZendFramework-1.10.5-minimal\library\Zend\Translate\Adapter\Ini.php:54
application.ini
resources.translate.registry_key = "Zend_Translate"
resources.translate.adapter = "ini"
resources.translate.data.directory = APPLICATION_PATH "/languages"
resources.translate.options.scan = "directory"
resources.translate.locale = "en"
directory structure
application\languages\
application\languages\en\component1.ini
application\languages\en\component2.ini
application\languages\el\component1.ini
application\languages\el\component2.ini
the culprit - Zend\Translate\Adapter\Ini.php
protected function _loadTranslationData($data, $locale, array $options = array()) {
$this->_data = array();
if (!file_exists($data)) {
require_once 'Zend/Translate/Exception.php';
throw new Zend_Translate_Exception("Ini file '".$data."' not found");
}
}
at this point var_dump($data) returns *
array(1) {
["directory"] =>string(45) "C:\www\projects\helloworld\application/languages"
}*
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是因为您的 $data 是“数组”,但应该是保存文件名的“字符串”。
为了检查文件是否存在于字符串数组中,您应该迭代该数组:
Its just because your $data is "array", but should be a "string" that holds a filename.
In order to check the files for existence in the array of strings you should iterate through that array: