Search code examples
zend-frameworkzend-translate

Zend Translate ini adapter exception "Ini file 'Array' not found"


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?


Solution

  • 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");
        }
    }