Zend Translate ini 适配器异常“Ini 文件‘数组’”未找到”

发布于 2024-09-08 18:18:02 字数 1255 浏览 4 评论 0原文

我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绻影浮沉 2024-09-15 18:18:02

这只是因为您的 $data 是“数组”,但应该是保存文件名的“字符串”。

为了检查文件是否存在于字符串数组中,您应该迭代该数组:

foreach ($data as $file) {
    if (!file_exists($file)) {  
         require_once 'Zend/Translate/Exception.php';  
         throw new Zend_Translate_Exception("Ini file '".$file."' not found");
    }
}

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:

foreach ($data as $file) {
    if (!file_exists($file)) {  
         require_once 'Zend/Translate/Exception.php';  
         throw new Zend_Translate_Exception("Ini file '".$file."' not found");
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文