View difference between Paste ID: f692f522 and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | <?php |
2 | ||
3 | // Sample config | |
4 | resources.translate.adapter = "gettext" | |
5 | resources.translate.data = APPLICATION_PATH "/../data/locales" | |
6 | resources.translate.options.disableNotices = true | |
7 | resources.translate.options.scan = "directory" | |
8 | ||
9 | ?> | |
10 | ||
11 | <?php | |
12 | /** | |
13 | * Zend Framework | |
14 | * | |
15 | * LICENSE | |
16 | * | |
17 | * This source file is subject to the new BSD license that is bundled | |
18 | * with this package in the file LICENSE.txt. | |
19 | * It is also available through the world-wide-web at this URL: | |
20 | * http://framework.zend.com/license/new-bsd | |
21 | * If you did not receive a copy of the license and are unable to | |
22 | * obtain it through the world-wide-web, please send an email | |
23 | * to license@zend.com so we can send you a copy immediately. | |
24 | * | |
25 | * @category Zend | |
26 | * @package Zend_Application | |
27 | * @subpackage Resource | |
28 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) | |
29 | * @license http://framework.zend.com/license/new-bsd New BSD License | |
30 | * @version $Id$ | |
31 | */ | |
32 | ||
33 | /** | |
34 | * Resource for setting translation options | |
35 | * | |
36 | * @uses Zend_Application_Resource_ResourceAbstract | |
37 | * @category Zend | |
38 | * @package Zend_Application | |
39 | * @subpackage Resource | |
40 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) | |
41 | * @license http://framework.zend.com/license/new-bsd New BSD License | |
42 | */ | |
43 | class Zend_Application_Resource_Translate | |
44 | extends Zend_Application_Resource_ResourceAbstract | |
45 | { | |
46 | const DEFAULT_REGISTRY_KEY = 'Zend_Translate'; | |
47 | ||
48 | /** | |
49 | * @var Zend_Translate | |
50 | */ | |
51 | protected $_translate; | |
52 | ||
53 | /** | |
54 | * Defined by Zend_Application_Resource_Resource | |
55 | * | |
56 | * @return Zend_Translate | |
57 | */ | |
58 | public function init() | |
59 | { | |
60 | return $this->getTranslate(); | |
61 | } | |
62 | ||
63 | /** | |
64 | * Retrieve translate object | |
65 | * | |
66 | * @return Zend_Translate | |
67 | */ | |
68 | public function getTranslate() | |
69 | { | |
70 | if (null === $this->_translate) { | |
71 | $options = $this->getOptions(); | |
72 | ||
73 | $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY; | |
74 | $data = isset($options['data']) ? $options['data'] : array(); | |
75 | $locale = isset($options['locale']) ? $options['locale'] : null; | |
76 | $translateOptions = isset($options['options']) ? $options['options'] : null; | |
77 | ||
78 | $this->_translate = new Zend_Translate($adapter, $data, $locale, $translateOptions); | |
79 | ||
80 | $key = (isset($options['registry_key']) && !is_numeric($options['registry_key'])) | |
81 | ? $options['registry_key'] | |
82 | : self::DEFAULT_REGISTRY_KEY; | |
83 | Zend_Registry::set($key, $this->_translate); | |
84 | } | |
85 | return $this->_translate; | |
86 | } | |
87 | } |