|
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: Array.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 */ |
|
21 |
|
22 |
|
23 /** Zend_Locale */ |
|
24 require_once 'Zend/Locale.php'; |
|
25 |
|
26 /** Zend_Translate_Adapter */ |
|
27 require_once 'Zend/Translate/Adapter.php'; |
|
28 |
|
29 |
|
30 /** |
|
31 * @category Zend |
|
32 * @package Zend_Translate |
|
33 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
35 */ |
|
36 class Zend_Translate_Adapter_Array extends Zend_Translate_Adapter |
|
37 { |
|
38 private $_data = array(); |
|
39 |
|
40 /** |
|
41 * Load translation data |
|
42 * |
|
43 * @param string|array $data |
|
44 * @param string $locale Locale/Language to add data for, identical with locale identifier, |
|
45 * see Zend_Locale for more information |
|
46 * @param array $options OPTIONAL Options to use |
|
47 * @return array |
|
48 */ |
|
49 protected function _loadTranslationData($data, $locale, array $options = array()) |
|
50 { |
|
51 $this->_data = array(); |
|
52 if (!is_array($data)) { |
|
53 if (file_exists($data)) { |
|
54 ob_start(); |
|
55 $data = include($data); |
|
56 ob_end_clean(); |
|
57 } |
|
58 } |
|
59 if (!is_array($data)) { |
|
60 require_once 'Zend/Translate/Exception.php'; |
|
61 throw new Zend_Translate_Exception("Error including array or file '".$data."'"); |
|
62 } |
|
63 |
|
64 if (!isset($this->_data[$locale])) { |
|
65 $this->_data[$locale] = array(); |
|
66 } |
|
67 |
|
68 $this->_data[$locale] = $data + $this->_data[$locale]; |
|
69 return $this->_data; |
|
70 } |
|
71 |
|
72 /** |
|
73 * returns the adapters name |
|
74 * |
|
75 * @return string |
|
76 */ |
|
77 public function toString() |
|
78 { |
|
79 return "Array"; |
|
80 } |
|
81 } |