2010-07-08 70 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"); 
    } 
}