*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Translate / Adapter / Array.php
blob42b1c3c50f1fad9280dbd8c57e37f222015fa4cf
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
23 /** Zend_Locale */
24 require_once 'Zend/Locale.php';
26 /** Zend_Translate_Adapter */
27 require_once 'Zend/Translate/Adapter.php';
30 /**
31 * @category Zend
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();
40 /**
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);
53 /**
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
60 * @return array
62 protected function _loadTranslationData($data, $locale, array $options = array())
64 $this->_data = array();
65 if (!is_array($data)) {
66 if (file_exists($data)) {
67 ob_start();
68 $data = include($data);
69 ob_end_clean();
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];
82 return $this->_data;
85 /**
86 * returns the adapters name
88 * @return string
90 public function toString()
92 return "Array";