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.
16 * @package Zend_Translate
17 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
18 * @version $Id: Array.php 16971 2009-07-22 18:05:45Z mikaelkael $
19 * @license http://framework.zend.com/license/new-bsd New BSD License
24 require_once 'Zend/Locale.php';
26 /** Zend_Translate_Adapter */
27 require_once 'Zend/Translate/Adapter.php';
32 * @package Zend_Translate
33 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license http://framework.zend.com/license/new-bsd New BSD License
36 class Zend_Translate_Adapter_Array
extends Zend_Translate_Adapter
38 private $_data = array();
41 * Generates the adapter
43 * @param array $data Translation data
44 * @param string|Zend_Locale $locale OPTIONAL Locale/Language to set, identical with locale identifier,
45 * see Zend_Locale for more information
46 * @param array $options OPTIONAL Options to set
48 public function __construct($data, $locale = null, array $options = array())
50 parent
::__construct($data, $locale, $options);
54 * Load translation data
56 * @param string|array $data
57 * @param string $locale Locale/Language to add data for, identical with locale identifier,
58 * see Zend_Locale for more information
59 * @param array $options OPTIONAL Options to use
62 protected function _loadTranslationData($data, $locale, array $options = array())
64 $this->_data
= array();
65 if (!is_array($data)) {
66 if (file_exists($data)) {
68 $data = include($data);
72 if (!is_array($data)) {
73 require_once 'Zend/Translate/Exception.php';
74 throw new Zend_Translate_Exception("Error including array or file '".$data."'");
77 if (!isset($this->_data
[$locale])) {
78 $this->_data
[$locale] = array();
81 $this->_data
[$locale] = $data +
$this->_data
[$locale];
86 * returns the adapters name
90 public function toString()