web/lib/Zend/Translate/Adapter/Gettext.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Translate
    16  * @package    Zend_Translate
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @version    $Id: Gettext.php 22653 2010-07-22 18:41:39Z mabe $
    18  * @version    $Id: Gettext.php 24593 2012-01-05 20:35:02Z matthew $
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  */
    20  */
    21 
    21 
    22 /** Zend_Locale */
    22 /** Zend_Locale */
    23 require_once 'Zend/Locale.php';
    23 require_once 'Zend/Locale.php';
    26 require_once 'Zend/Translate/Adapter.php';
    26 require_once 'Zend/Translate/Adapter.php';
    27 
    27 
    28 /**
    28 /**
    29  * @category   Zend
    29  * @category   Zend
    30  * @package    Zend_Translate
    30  * @package    Zend_Translate
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  */
    33  */
    34 class Zend_Translate_Adapter_Gettext extends Zend_Translate_Adapter {
    34 class Zend_Translate_Adapter_Gettext extends Zend_Translate_Adapter {
    35     // Internal variables
    35     // Internal variables
    36     private $_bigEndian   = false;
    36     private $_bigEndian   = false;
    70         if (!$this->_file) {
    70         if (!$this->_file) {
    71             require_once 'Zend/Translate/Exception.php';
    71             require_once 'Zend/Translate/Exception.php';
    72             throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
    72             throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
    73         }
    73         }
    74         if (@filesize($filename) < 10) {
    74         if (@filesize($filename) < 10) {
       
    75             @fclose($this->_file);
    75             require_once 'Zend/Translate/Exception.php';
    76             require_once 'Zend/Translate/Exception.php';
    76             throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
    77             throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
    77         }
    78         }
    78 
    79 
    79         // get Endian
    80         // get Endian
    81         if (strtolower(substr(dechex($input[1]), -8)) == "950412de") {
    82         if (strtolower(substr(dechex($input[1]), -8)) == "950412de") {
    82             $this->_bigEndian = false;
    83             $this->_bigEndian = false;
    83         } else if (strtolower(substr(dechex($input[1]), -8)) == "de120495") {
    84         } else if (strtolower(substr(dechex($input[1]), -8)) == "de120495") {
    84             $this->_bigEndian = true;
    85             $this->_bigEndian = true;
    85         } else {
    86         } else {
       
    87             @fclose($this->_file);
    86             require_once 'Zend/Translate/Exception.php';
    88             require_once 'Zend/Translate/Exception.php';
    87             throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
    89             throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
    88         }
    90         }
    89         // read revision - not supported for now
    91         // read revision - not supported for now
    90         $input = $this->_readMOData(1);
    92         $input = $this->_readMOData(1);
   129                 } else {
   131                 } else {
   130                     $this->_data[$locale][$original[0]] = $translate[0];
   132                     $this->_data[$locale][$original[0]] = $translate[0];
   131                 }
   133                 }
   132             }
   134             }
   133         }
   135         }
       
   136         
       
   137         @fclose($this->_file);
   134 
   138 
   135         $this->_data[$locale][''] = trim($this->_data[$locale]['']);
   139         $this->_data[$locale][''] = trim($this->_data[$locale]['']);
   136         if (empty($this->_data[$locale][''])) {
   140         if (empty($this->_data[$locale][''])) {
   137             $this->_adapterInfo[$filename] = 'No adapter information available';
   141             $this->_adapterInfo[$filename] = 'No adapter information available';
   138         } else {
   142         } else {