|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
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. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Translate |
|
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @version $Id: Ini.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 */ |
|
21 |
|
22 /** Zend_Locale */ |
|
23 require_once 'Zend/Locale.php'; |
|
24 |
|
25 /** Zend_Translate_Adapter */ |
|
26 require_once 'Zend/Translate/Adapter.php'; |
|
27 |
|
28 /** |
|
29 * @category Zend |
|
30 * @package Zend_Translate |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_Translate_Adapter_Ini extends Zend_Translate_Adapter |
|
35 { |
|
36 private $_data = array(); |
|
37 |
|
38 /** |
|
39 * Load translation data |
|
40 * |
|
41 * @param string|array $data |
|
42 * @param string $locale Locale/Language to add data for, identical with locale identifier, |
|
43 * see Zend_Locale for more information |
|
44 * @param array $options OPTIONAL Options to use |
|
45 * @throws Zend_Translate_Exception Ini file not found |
|
46 * @return array |
|
47 */ |
|
48 protected function _loadTranslationData($data, $locale, array $options = array()) |
|
49 { |
|
50 $this->_data = array(); |
|
51 if (!file_exists($data)) { |
|
52 require_once 'Zend/Translate/Exception.php'; |
|
53 throw new Zend_Translate_Exception("Ini file '".$data."' not found"); |
|
54 } |
|
55 |
|
56 $inidata = parse_ini_file($data, false); |
|
57 if (!isset($this->_data[$locale])) { |
|
58 $this->_data[$locale] = array(); |
|
59 } |
|
60 |
|
61 $this->_data[$locale] = array_merge($this->_data[$locale], $inidata); |
|
62 return $this->_data; |
|
63 } |
|
64 |
|
65 /** |
|
66 * returns the adapters name |
|
67 * |
|
68 * @return string |
|
69 */ |
|
70 public function toString() |
|
71 { |
|
72 return "Ini"; |
|
73 } |
|
74 } |