2010-07-08 69 views
-1

我从Zend的一个丑陋的异常翻译:Zend的翻译INI适配器例外“INI文件‘数组’未找到”

致命错误:未捕获的异常“Zend_Translate_Exception”有消息“INI文件‘阵中’未发现” C:\ WWW \库\ ZendFramework-1.10.5-最小\库\ Zend的\翻译\适配器\ 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”

目录结构

应用程序\语言\
应用程序\语言\ EN \ component1.ini
应用程序\语言\ EN \ component2.ini
应用程序\语言\ EL \ component1.ini
种应用程序\语言\ EL \ component2.ini

的罪魁祸首 - Zend的\翻译\适配器\ 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" 
}* 

我在做什么错了?

+0

因为这是它很难unerstand你应该格式化代码。 – Iznogood 2010-07-08 05:04:47

+0

刚发现双空格 - > br在markdown :) – yannis 2010-07-08 05:08:40

回答

2

它只是因为你的$数据是“数组”,但应该是一个保存文件名的“字符串”。

为了检查文件生存,你应该通过遍历数组字符串数组中:

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