File indexing completed on 2024-06-16 05:30:32

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Translate
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @version    $Id$
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  */
0021 
0022 /** Zend_Locale */
0023 // require_once 'Zend/Locale.php';
0024 
0025 /** Zend_Translate_Adapter */
0026 // require_once 'Zend/Translate/Adapter.php';
0027 
0028 /**
0029  * @category   Zend
0030  * @package    Zend_Translate
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_Translate_Adapter_Ini extends Zend_Translate_Adapter
0035 {
0036     private $_data = array();
0037 
0038     /**
0039      * Load translation data
0040      *
0041      * @param  string|array  $data
0042      * @param  string        $locale  Locale/Language to add data for, identical with locale identifier,
0043      *                                see Zend_Locale for more information
0044      * @param  array         $options OPTIONAL Options to use
0045      * @throws Zend_Translate_Exception Ini file not found
0046      * @return array
0047      */
0048     protected function _loadTranslationData($data, $locale, array $options = array())
0049     {
0050         $this->_data = array();
0051         if (!file_exists($data)) {
0052             // require_once 'Zend/Translate/Exception.php';
0053             throw new Zend_Translate_Exception("Ini file '".$data."' not found");
0054         }
0055 
0056         $inidata = parse_ini_file($data, false);
0057         if (!isset($this->_data[$locale])) {
0058             $this->_data[$locale] = array();
0059         }
0060 
0061         $this->_data[$locale] = array_merge($this->_data[$locale], $inidata);
0062         return $this->_data;
0063     }
0064 
0065     /**
0066      * returns the adapters name
0067      *
0068      * @return string
0069      */
0070     public function toString()
0071     {
0072         return "Ini";
0073     }
0074 }