Version Notes
1.7.2
Download this release
Release Info
Developer | Magento Core Team |
Extension | Lib_ZF_Locale |
Version | 1.7.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.7.2
- lib/Zend/Locale.php +538 -409
- lib/Zend/Locale/Data.php +73 -34
- lib/Zend/Locale/Data/Translation.php +15 -12
- lib/Zend/Locale/Data/aa.xml +5 -6
- lib/Zend/Locale/Data/aa_DJ.xml +3 -4
- lib/Zend/Locale/Data/aa_ER.xml +3 -4
- lib/Zend/Locale/Data/aa_ER_SAAHO.xml +0 -40
- lib/Zend/Locale/Data/aa_ET.xml +3 -4
- lib/Zend/Locale/Data/af.xml +101 -6
- lib/Zend/Locale/Data/af_NA.xml +4 -4
- lib/Zend/Locale/Data/af_ZA.xml +3 -4
- lib/Zend/Locale/Data/ak.xml +3 -3
- lib/Zend/Locale/Data/ak_GH.xml +3 -4
- lib/Zend/Locale/Data/am.xml +89 -17
- lib/Zend/Locale/Data/am_ET.xml +3 -4
- lib/Zend/Locale/Data/ar.xml +230 -67
- lib/Zend/Locale/Data/ar_AE.xml +3 -4
- lib/Zend/Locale/Data/ar_BH.xml +3 -4
- lib/Zend/Locale/Data/ar_DZ.xml +3 -4
- lib/Zend/Locale/Data/ar_EG.xml +3 -4
- lib/Zend/Locale/Data/ar_IQ.xml +3 -4
- lib/Zend/Locale/Data/ar_JO.xml +3 -4
- lib/Zend/Locale/Data/ar_KW.xml +3 -4
- lib/Zend/Locale/Data/ar_LB.xml +3 -3
- lib/Zend/Locale/Data/ar_LY.xml +3 -4
- lib/Zend/Locale/Data/ar_MA.xml +3 -4
- lib/Zend/Locale/Data/ar_OM.xml +3 -4
- lib/Zend/Locale/Data/ar_QA.xml +3 -4
- lib/Zend/Locale/Data/ar_SA.xml +3 -4
- lib/Zend/Locale/Data/ar_SD.xml +3 -4
- lib/Zend/Locale/Data/ar_SY.xml +3 -4
- lib/Zend/Locale/Data/ar_TN.xml +3 -4
- lib/Zend/Locale/Data/ar_YE.xml +3 -4
- lib/Zend/Locale/Data/as.xml +47 -4
- lib/Zend/Locale/Data/as_IN.xml +3 -4
- lib/Zend/Locale/Data/az.xml +2522 -99
- lib/Zend/Locale/Data/az_AZ.xml +3 -3
- lib/Zend/Locale/Data/az_Cyrl.xml +3 -4
- lib/Zend/Locale/Data/az_Cyrl_AZ.xml +3 -4
- lib/Zend/Locale/Data/az_Latn.xml +3 -4
- lib/Zend/Locale/Data/az_Latn_AZ.xml +3 -4
- lib/Zend/Locale/Data/be.xml +397 -115
- lib/Zend/Locale/Data/be_BY.xml +3 -4
- lib/Zend/Locale/Data/bg.xml +115 -87
- lib/Zend/Locale/Data/bg_BG.xml +3 -4
- lib/Zend/Locale/Data/bn.xml +2394 -241
- lib/Zend/Locale/Data/bn_BD.xml +3 -4
- lib/Zend/Locale/Data/bn_IN.xml +19 -3
- lib/Zend/Locale/Data/bo.xml +0 -506
- lib/Zend/Locale/Data/bo_CN.xml +0 -10
- lib/Zend/Locale/Data/bo_IN.xml +0 -11
- lib/Zend/Locale/Data/bs.xml +3 -4
- lib/Zend/Locale/Data/bs_BA.xml +3 -4
- lib/Zend/Locale/Data/byn.xml +3 -4
- lib/Zend/Locale/Data/byn_ER.xml +3 -4
- lib/Zend/Locale/Data/ca.xml +672 -40
- lib/Zend/Locale/Data/ca_ES.xml +3 -4
- lib/Zend/Locale/Data/cch.xml +3 -4
- lib/Zend/Locale/Data/cch_NG.xml +3 -4
- lib/Zend/Locale/Data/characters.xml +1888 -0
- lib/Zend/Locale/Data/cop.xml +3 -3
- lib/Zend/Locale/Data/cop_Arab.xml +0 -23
- lib/Zend/Locale/Data/cop_Arab_EG.xml +0 -12
- lib/Zend/Locale/Data/cop_Arab_US.xml +0 -12
- lib/Zend/Locale/Data/cop_EG.xml +0 -11
- lib/Zend/Locale/Data/cop_US.xml +0 -11
- lib/Zend/Locale/Data/cs.xml +194 -86
- lib/Zend/Locale/Data/cs_CZ.xml +3 -4
- lib/Zend/Locale/Data/cy.xml +200 -45
- lib/Zend/Locale/Data/cy_GB.xml +3 -4
- lib/Zend/Locale/Data/da.xml +737 -70
- lib/Zend/Locale/Data/da_DK.xml +3 -4
- lib/Zend/Locale/Data/de.xml +764 -108
- lib/Zend/Locale/Data/de_AT.xml +27 -4
- lib/Zend/Locale/Data/de_BE.xml +51 -3
- lib/Zend/Locale/Data/de_CH.xml +4 -4
- lib/Zend/Locale/Data/de_DE.xml +3 -4
- lib/Zend/Locale/Data/de_LI.xml +4 -4
- lib/Zend/Locale/Data/de_LU.xml +3 -4
- lib/Zend/Locale/Data/dv.xml +7 -4
- lib/Zend/Locale/Data/dv_MV.xml +3 -4
- lib/Zend/Locale/Data/dz.xml +4 -5
- lib/Zend/Locale/Data/dz_BT.xml +3 -4
- lib/Zend/Locale/Data/ee.xml +3 -3
- lib/Zend/Locale/Data/ee_GH.xml +3 -4
- lib/Zend/Locale/Data/ee_TG.xml +3 -4
- lib/Zend/Locale/Data/el.xml +178 -70
- lib/Zend/Locale/Data/el_CY.xml +3 -4
- lib/Zend/Locale/Data/el_GR.xml +3 -4
- lib/Zend/Locale/Data/el_POLYTON.xml +3 -3
- lib/Zend/Locale/Data/el_POLYTONI.xml +0 -559
- lib/Zend/Locale/Data/en.xml +825 -620
- lib/Zend/Locale/Data/en_AS.xml +3 -4
- lib/Zend/Locale/Data/en_AU.xml +80 -3
- lib/Zend/Locale/Data/en_BE.xml +77 -4
- lib/Zend/Locale/Data/en_BW.xml +80 -4
- lib/Zend/Locale/Data/en_BZ.xml +88 -4
- lib/Zend/Locale/Data/en_CA.xml +81 -4
- lib/Zend/Locale/Data/en_GB.xml +75 -3
- lib/Zend/Locale/Data/en_GU.xml +3 -4
- lib/Zend/Locale/Data/en_HK.xml +80 -4
- lib/Zend/Locale/Data/en_IE.xml +73 -3
- lib/Zend/Locale/Data/en_IN.xml +81 -4
- lib/Zend/Locale/Data/en_JM.xml +3 -4
- lib/Zend/Locale/Data/en_MH.xml +3 -4
- lib/Zend/Locale/Data/en_MP.xml +3 -4
- lib/Zend/Locale/Data/en_MT.xml +54 -3
lib/Zend/Locale.php
CHANGED
@@ -12,94 +12,164 @@
|
|
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
|
16 |
-
* @package
|
17 |
-
* @copyright
|
18 |
-
* @
|
19 |
-
* @
|
20 |
*/
|
21 |
|
22 |
-
|
23 |
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* @
|
27 |
-
* @
|
|
|
|
|
28 |
*/
|
29 |
-
class Zend_Locale
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
private static $_localeData = array(
|
33 |
-
'root' => true, 'aa_DJ' => true, 'aa_ER' => true, 'aa_ET' => true, 'aa' => true,
|
34 |
-
'
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
'
|
40 |
-
'
|
41 |
-
'
|
42 |
-
'
|
43 |
-
'
|
44 |
-
'
|
45 |
-
'
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
'
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
);
|
74 |
|
75 |
-
|
76 |
/**
|
77 |
* Autosearch constants
|
78 |
*/
|
79 |
-
const BROWSER =
|
80 |
-
const ENVIRONMENT =
|
81 |
-
const
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
/**
|
85 |
* Actual set locale
|
|
|
|
|
86 |
*/
|
87 |
-
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
/**
|
91 |
-
*
|
|
|
|
|
92 |
*/
|
93 |
-
|
94 |
|
95 |
/**
|
96 |
-
*
|
|
|
|
|
97 |
*/
|
98 |
-
|
99 |
-
private static $_browser;
|
100 |
-
private static $_environment;
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
/**
|
105 |
* Generates a locale object
|
@@ -111,28 +181,15 @@ class Zend_Locale {
|
|
111 |
* 3. Server Environment
|
112 |
* 4. Framework Standard
|
113 |
*
|
114 |
-
* @param string
|
115 |
-
* @throws Zend_Locale_Exception
|
116 |
*/
|
117 |
public function __construct($locale = null)
|
118 |
{
|
119 |
-
|
120 |
-
|
121 |
-
self::$_browser = $this->getDefault(self::BROWSER, false);
|
122 |
-
self::$_environment = $this->getDefault(self::ENVIRONMENT, false);
|
123 |
-
if (empty($locale) and empty(self::$_auto) and empty(self::$_Default)) {
|
124 |
-
#require_once 'Zend/Locale/Exception.php';
|
125 |
-
throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
if ($locale instanceof Zend_Locale) {
|
130 |
-
$locale = $locale->toString();
|
131 |
-
}
|
132 |
-
$this->setLocale($locale);
|
133 |
}
|
134 |
|
135 |
-
|
136 |
/**
|
137 |
* Serialization Interface
|
138 |
*
|
@@ -143,7 +200,6 @@ class Zend_Locale {
|
|
143 |
return serialize($this);
|
144 |
}
|
145 |
|
146 |
-
|
147 |
/**
|
148 |
* Returns a string representation of the object
|
149 |
*
|
@@ -151,10 +207,9 @@ class Zend_Locale {
|
|
151 |
*/
|
152 |
public function toString()
|
153 |
{
|
154 |
-
return (string) $this->
|
155 |
}
|
156 |
|
157 |
-
|
158 |
/**
|
159 |
* Returns a string representation of the object
|
160 |
* Alias for toString
|
@@ -166,92 +221,73 @@ class Zend_Locale {
|
|
166 |
return $this->toString();
|
167 |
}
|
168 |
|
169 |
-
|
170 |
/**
|
171 |
-
*
|
172 |
-
* ordered by quality
|
173 |
-
*
|
174 |
-
* Standard Searchorder is
|
175 |
-
* - getBrowser
|
176 |
-
* - getEnvironment
|
177 |
-
* - getFramework
|
178 |
*
|
179 |
-
* @
|
180 |
-
* @param $fastsearch - OPTIONAL returnes the first found locale array when true
|
181 |
-
* otherwise all found default locales will be returned
|
182 |
-
* @return locale - returns an array of all the mosta locale string
|
183 |
*/
|
184 |
-
public function getDefault(
|
185 |
{
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
$
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
} else if ($searchorder == self::FRAMEWORK) {
|
198 |
-
|
199 |
-
$languages = $this->getFramework();
|
200 |
-
if (empty($languages) or !$fastsearch) {
|
201 |
-
$languages = array_merge($languages, $this->getEnvironment());
|
202 |
-
}
|
203 |
-
if (empty($languages) or !$fastsearch) {
|
204 |
-
$languages = array_merge($languages, $this->getBrowser());
|
205 |
-
}
|
206 |
-
|
207 |
-
} else {
|
208 |
-
|
209 |
-
$languages = $this->getBrowser();
|
210 |
-
if (empty($languages) or !$fastsearch) {
|
211 |
-
$languages = array_merge($languages, $this->getEnvironment());
|
212 |
-
}
|
213 |
-
if (empty($languages) or !$fastsearch) {
|
214 |
-
$languages = array_merge($languages, $this->getFramework());
|
215 |
}
|
216 |
|
|
|
217 |
}
|
218 |
|
219 |
-
|
220 |
-
$languages[self::$_Default] = 0.1;
|
221 |
-
}
|
222 |
-
return $languages;
|
223 |
}
|
224 |
|
225 |
-
|
226 |
/**
|
227 |
* Sets a new default locale
|
|
|
|
|
|
|
228 |
*
|
229 |
-
* @param
|
230 |
-
* @
|
231 |
-
* @throws Zend_Locale_Exception
|
|
|
|
|
232 |
*/
|
233 |
-
public static function setDefault($locale)
|
234 |
{
|
235 |
-
if (($locale
|
236 |
-
($locale
|
237 |
#require_once 'Zend/Locale/Exception.php';
|
238 |
throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
|
239 |
}
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
} else {
|
244 |
-
$locale = explode('_', $locale);
|
245 |
-
if (
|
246 |
-
self::$
|
247 |
-
|
|
|
|
|
248 |
}
|
249 |
}
|
250 |
-
#require_once 'Zend/Locale/Exception.php';
|
251 |
-
throw new Zend_Locale_Exception("Unknown locale '$locale' can not be set as default!");
|
252 |
}
|
253 |
|
254 |
-
|
255 |
/**
|
256 |
* Expects the Systems standard locale
|
257 |
*
|
@@ -261,46 +297,54 @@ class Zend_Locale {
|
|
261 |
*
|
262 |
* @return array
|
263 |
*/
|
264 |
-
public function getEnvironment()
|
265 |
{
|
266 |
-
|
|
|
|
|
267 |
|
268 |
-
|
269 |
-
$languages = explode(';', $language);
|
270 |
|
|
|
|
|
271 |
$languagearray = array();
|
272 |
|
273 |
foreach ($languages as $locale) {
|
274 |
-
|
275 |
if (strpos($locale, '=') !== false) {
|
276 |
$language = substr($locale, strpos($locale, '='));
|
277 |
$language = substr($language, 1);
|
278 |
}
|
279 |
|
280 |
-
if ($language
|
281 |
if (strpos($language, '.') !== false) {
|
282 |
-
$language = substr($language, 0, strpos($language, '.') - 1);
|
283 |
} else if (strpos($language, '@') !== false) {
|
284 |
-
$language = substr($language, 0, strpos($language, '@') - 1);
|
285 |
}
|
|
|
286 |
$splitted = explode('_', $language);
|
287 |
-
|
|
|
288 |
$languagearray[$language] = 1;
|
289 |
if (strlen($language) > 4) {
|
290 |
$languagearray[substr($language, 0, 2)] = 1;
|
291 |
}
|
|
|
292 |
continue;
|
293 |
}
|
294 |
|
295 |
-
if (
|
296 |
-
if (
|
297 |
-
$languagearray[Zend_Locale_Data_Translation::$localeTranslation[$splitted[0]] . '_'
|
298 |
-
|
299 |
}
|
|
|
300 |
$languagearray[Zend_Locale_Data_Translation::$localeTranslation[$splitted[0]]] = 1;
|
301 |
}
|
302 |
}
|
303 |
}
|
|
|
|
|
304 |
return $languagearray;
|
305 |
}
|
306 |
|
@@ -313,105 +357,86 @@ class Zend_Locale {
|
|
313 |
*
|
314 |
* @return array - list of accepted languages including quality
|
315 |
*/
|
316 |
-
public function getBrowser()
|
317 |
{
|
318 |
-
|
|
|
|
|
319 |
|
320 |
-
$
|
321 |
-
|
|
|
322 |
return $languages;
|
323 |
}
|
324 |
|
325 |
$accepted = preg_split('/,\s*/', $httplanguages);
|
326 |
|
327 |
foreach ($accepted as $accept) {
|
|
|
328 |
$result = preg_match('/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
|
329 |
$accept, $match);
|
330 |
|
331 |
-
if (
|
332 |
continue;
|
333 |
}
|
334 |
|
335 |
-
if (isset($match[2])) {
|
336 |
$quality = (float) $match[2];
|
337 |
} else {
|
338 |
$quality = 1.0;
|
339 |
}
|
340 |
|
341 |
$countrys = explode('-', $match[1]);
|
342 |
-
$region
|
343 |
|
344 |
$country2 = explode('_', $region);
|
345 |
-
$region
|
346 |
|
347 |
-
foreach($countrys as $country) {
|
348 |
$languages[$region . '_' . strtoupper($country)] = $quality;
|
349 |
}
|
350 |
-
|
|
|
351 |
$languages[$region . '_' . strtoupper($country)] = $quality;
|
352 |
}
|
353 |
-
|
|
|
354 |
$languages[$region] = $quality;
|
355 |
}
|
356 |
}
|
357 |
-
return $languages;
|
358 |
-
}
|
359 |
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Returns the locale which the framework is set to
|
363 |
-
*
|
364 |
-
* @return array
|
365 |
-
*/
|
366 |
-
public function getFramework()
|
367 |
-
{
|
368 |
-
$languages = array();
|
369 |
return $languages;
|
370 |
}
|
371 |
|
372 |
-
|
373 |
/**
|
374 |
* Sets a new locale
|
375 |
*
|
376 |
-
* @param
|
|
|
377 |
*/
|
378 |
public function setLocale($locale = null)
|
379 |
{
|
380 |
-
|
381 |
-
$locale = $this->getDefault($locale, true);
|
382 |
-
}
|
383 |
|
384 |
-
if ((
|
385 |
-
$
|
386 |
-
|
387 |
-
|
388 |
-
$locale = self::$_browser;
|
389 |
-
}
|
390 |
-
if ($locale == 'environment') {
|
391 |
-
$locale = self::$_environment;
|
392 |
-
}
|
393 |
-
if (is_array($locale)) {
|
394 |
-
$locale = key($locale);
|
395 |
-
}
|
396 |
-
if (!array_key_exists((string) $locale, self::$_localeData)) {
|
397 |
-
$region = substr($locale, 0, 3);
|
398 |
-
if (isset($region[2])) {
|
399 |
-
if (($region[2] == '_') or ($region[2] == '-')) {
|
400 |
$region = substr($region, 0, 2);
|
401 |
}
|
402 |
}
|
403 |
-
|
404 |
-
|
|
|
405 |
} else {
|
406 |
-
$this->
|
407 |
}
|
408 |
-
|
409 |
} else {
|
410 |
-
$this->
|
411 |
}
|
412 |
}
|
413 |
|
414 |
-
|
415 |
/**
|
416 |
* Returns the language part of the locale
|
417 |
*
|
@@ -419,11 +444,10 @@ class Zend_Locale {
|
|
419 |
*/
|
420 |
public function getLanguage()
|
421 |
{
|
422 |
-
$locale = explode('_', $this->
|
423 |
return $locale[0];
|
424 |
}
|
425 |
|
426 |
-
|
427 |
/**
|
428 |
* Returns the region part of the locale if available
|
429 |
*
|
@@ -431,23 +455,22 @@ class Zend_Locale {
|
|
431 |
*/
|
432 |
public function getRegion()
|
433 |
{
|
434 |
-
$locale = explode('_', $this->
|
435 |
-
if (isset($locale[1])) {
|
436 |
return $locale[1];
|
437 |
}
|
438 |
|
439 |
return false;
|
440 |
}
|
441 |
|
442 |
-
|
443 |
/**
|
444 |
* Return the accepted charset of the client
|
445 |
-
*
|
446 |
* @return string
|
447 |
*/
|
448 |
-
public function getHttpCharset()
|
449 |
{
|
450 |
-
$httpcharsets = getenv(
|
451 |
|
452 |
$charsets = array();
|
453 |
if ($httpcharsets === false) {
|
@@ -455,362 +478,332 @@ class Zend_Locale {
|
|
455 |
}
|
456 |
|
457 |
$accepted = preg_split('/,\s*/', $httpcharsets);
|
458 |
-
foreach ($accepted as $accept)
|
459 |
-
|
460 |
-
if (empty($accept)) {
|
461 |
continue;
|
462 |
}
|
463 |
|
464 |
-
if (strpos($accept, ';'))
|
465 |
-
|
466 |
-
$
|
467 |
-
$charsets[
|
468 |
} else {
|
469 |
-
$quality
|
470 |
$charsets[$accept] = $quality;
|
471 |
}
|
472 |
-
|
473 |
}
|
474 |
|
475 |
return $charsets;
|
476 |
}
|
477 |
|
478 |
-
|
479 |
/**
|
480 |
* Returns true if both locales are equal
|
481 |
*
|
|
|
482 |
* @return boolean
|
483 |
*/
|
484 |
-
public function equals($object)
|
485 |
{
|
486 |
-
if ($object->toString()
|
487 |
return true;
|
488 |
}
|
489 |
|
490 |
return false;
|
491 |
}
|
492 |
|
493 |
-
|
494 |
/**
|
495 |
* Returns localized informations as array, supported are several
|
496 |
* types of informations.
|
497 |
* For detailed information about the types look into the documentation
|
498 |
*
|
499 |
-
* @param string
|
500 |
-
* @param string|
|
501 |
-
* @param string
|
502 |
-
* @return array
|
503 |
*/
|
504 |
-
public function getTranslationList($path = null, $locale = null, $value = null)
|
505 |
{
|
506 |
-
// load class within method for speed
|
507 |
#require_once 'Zend/Locale/Data.php';
|
508 |
-
|
509 |
-
|
510 |
-
if ($locale === null) {
|
511 |
-
$locale = $this->_Locale;
|
512 |
-
}
|
513 |
-
|
514 |
-
if ($locale == 'auto') {
|
515 |
-
$locale = self::$_auto;
|
516 |
-
}
|
517 |
-
if ($locale == 'browser') {
|
518 |
-
$locale = self::$_browser;
|
519 |
-
}
|
520 |
-
if ($locale == 'environment') {
|
521 |
-
$locale = self::$_environment;
|
522 |
-
}
|
523 |
-
if (is_array($locale)) {
|
524 |
-
$locale = key($locale);
|
525 |
-
}
|
526 |
$result = Zend_Locale_Data::getList($locale, $path, $value);
|
527 |
-
if (empty($result)) {
|
528 |
return false;
|
529 |
}
|
|
|
530 |
return $result;
|
531 |
}
|
532 |
|
533 |
-
|
534 |
/**
|
535 |
* Returns an array with the name of all languages translated to the given language
|
536 |
*
|
537 |
-
* @param
|
538 |
-
* @return
|
539 |
*/
|
540 |
-
public function getLanguageTranslationList($locale = null)
|
541 |
{
|
542 |
-
return
|
543 |
}
|
544 |
|
545 |
-
|
546 |
/**
|
547 |
* Returns an array with the name of all scripts translated to the given language
|
548 |
*
|
549 |
-
* @param
|
550 |
-
* @return
|
551 |
*/
|
552 |
-
public function getScriptTranslationList($locale = null)
|
553 |
{
|
554 |
-
return
|
555 |
}
|
556 |
|
557 |
-
|
558 |
/**
|
559 |
* Returns an array with the name of all countries translated to the given language
|
560 |
*
|
561 |
-
* @param
|
562 |
-
* @return
|
563 |
*/
|
564 |
-
public function getCountryTranslationList($locale = null)
|
565 |
{
|
566 |
-
return
|
567 |
}
|
568 |
|
569 |
-
|
570 |
/**
|
571 |
* Returns an array with the name of all territories translated to the given language
|
572 |
* All territories contains other countries.
|
573 |
*
|
574 |
-
* @param
|
575 |
-
* @return
|
576 |
*/
|
577 |
-
public function getTerritoryTranslationList($locale = null)
|
578 |
{
|
579 |
-
return
|
580 |
}
|
581 |
|
582 |
-
|
583 |
/**
|
584 |
* Returns a localized information string, supported are several types of informations.
|
585 |
* For detailed information about the types look into the documentation
|
586 |
*
|
587 |
-
* @param string
|
588 |
-
* @param string
|
589 |
-
* @param string|
|
590 |
-
* @return string
|
591 |
*/
|
592 |
-
public function getTranslation($value = null, $path = null, $locale = null)
|
593 |
{
|
594 |
-
// load class within method for speed
|
595 |
#require_once 'Zend/Locale/Data.php';
|
596 |
-
|
597 |
-
|
598 |
-
if ($locale === null) {
|
599 |
-
$locale = $this->_Locale;
|
600 |
-
}
|
601 |
-
|
602 |
-
if ($locale == 'auto') {
|
603 |
-
$locale = self::$_auto;
|
604 |
-
}
|
605 |
-
if ($locale == 'browser') {
|
606 |
-
$locale = self::$_browser;
|
607 |
-
}
|
608 |
-
if ($locale == 'environment') {
|
609 |
-
$locale = self::$_environment;
|
610 |
-
}
|
611 |
-
if (is_array($locale)) {
|
612 |
-
$locale = key($locale);
|
613 |
-
}
|
614 |
$result = Zend_Locale_Data::getContent($locale, $path, $value);
|
615 |
-
if (empty($result)) {
|
616 |
return false;
|
617 |
}
|
|
|
618 |
return $result;
|
619 |
}
|
620 |
|
621 |
-
|
622 |
/**
|
623 |
* Returns the localized language name
|
624 |
*
|
625 |
-
* @param
|
626 |
-
* @param
|
627 |
-
* @return
|
628 |
*/
|
629 |
-
public function getLanguageTranslation($value, $locale = null)
|
630 |
{
|
631 |
-
return
|
632 |
}
|
633 |
|
634 |
-
|
635 |
/**
|
636 |
* Returns the localized script name
|
637 |
*
|
638 |
-
* @param
|
639 |
-
* @param
|
640 |
-
* @return
|
641 |
*/
|
642 |
-
public function getScriptTranslation($value, $locale = null)
|
643 |
{
|
644 |
-
return
|
645 |
}
|
646 |
|
647 |
-
|
648 |
/**
|
649 |
* Returns the localized country name
|
650 |
*
|
651 |
-
* @param
|
652 |
-
* @param
|
653 |
-
* @return
|
654 |
*/
|
655 |
-
public function getCountryTranslation($value, $locale = null)
|
656 |
{
|
657 |
-
return
|
658 |
}
|
659 |
|
660 |
-
|
661 |
/**
|
662 |
* Returns the localized territory name
|
663 |
* All territories contains other countries.
|
664 |
*
|
665 |
-
* @param
|
666 |
-
* @param
|
667 |
-
* @return
|
668 |
*/
|
669 |
-
public function getTerritoryTranslation($value, $locale = null)
|
670 |
{
|
671 |
-
return
|
672 |
}
|
673 |
|
674 |
-
|
675 |
/**
|
676 |
* Returns an array with translated yes strings
|
677 |
*
|
678 |
-
* @param string
|
679 |
* @return array
|
680 |
*/
|
681 |
-
public function getQuestion($locale = null)
|
682 |
{
|
683 |
-
// load class within method for speed
|
684 |
#require_once 'Zend/Locale/Data.php';
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
if ($locale == 'auto') {
|
691 |
-
$locale = self::$_auto;
|
692 |
-
}
|
693 |
-
if ($locale == 'browser') {
|
694 |
-
$locale = self::$_browser;
|
695 |
-
}
|
696 |
-
if ($locale == 'environment') {
|
697 |
-
$locale = self::$_environment;
|
698 |
-
}
|
699 |
-
if (is_array($locale)) {
|
700 |
-
$locale = key($locale);
|
701 |
-
}
|
702 |
-
$quest = Zend_Locale_Data::getList($locale, 'question');
|
703 |
-
$yes = explode(':', $quest['yes']);
|
704 |
-
$no = explode(':', $quest['no']);
|
705 |
$quest['yes'] = $yes[0];
|
706 |
$quest['yesarray'] = $yes;
|
707 |
$quest['no'] = $no[0];
|
708 |
$quest['noarray'] = $no;
|
709 |
-
$quest['yesexpr'] =
|
710 |
-
$quest['noexpr'] =
|
711 |
|
712 |
return $quest;
|
713 |
}
|
714 |
|
715 |
-
|
716 |
/**
|
717 |
-
* Internal function for
|
718 |
*
|
719 |
-
* @param
|
720 |
* @return string
|
721 |
*/
|
722 |
-
private function
|
723 |
{
|
724 |
-
$regex =
|
725 |
-
if (is_array($input)) {
|
726 |
-
$regex =
|
727 |
$start = true;
|
728 |
-
foreach($input as $row) {
|
729 |
if ($start === false) {
|
730 |
-
$regex .=
|
731 |
}
|
732 |
-
|
733 |
-
$
|
734 |
-
$
|
|
|
735 |
if (strlen($row) > 2) {
|
736 |
$one = true;
|
737 |
}
|
|
|
738 |
foreach (str_split($row, 1) as $char) {
|
739 |
-
$regex .=
|
740 |
-
$regex .= strtoupper($char) .
|
741 |
if ($one === true) {
|
742 |
-
$one
|
743 |
-
$regex .=
|
744 |
}
|
745 |
}
|
|
|
746 |
if ($one === false) {
|
747 |
-
$regex .=
|
748 |
}
|
749 |
-
|
|
|
750 |
}
|
751 |
}
|
|
|
752 |
return $regex;
|
753 |
}
|
754 |
|
755 |
-
|
756 |
/**
|
757 |
* Checks if a locale identifier is a real locale or not
|
758 |
* Examples:
|
759 |
* "en_XX" refers to "en", which returns true
|
760 |
* "XX_yy" refers to "root", which returns false
|
761 |
*
|
762 |
-
* @param string|Zend_Locale
|
763 |
-
* @param boolean
|
764 |
-
* @
|
|
|
765 |
*/
|
766 |
-
public static function isLocale($locale, $
|
767 |
{
|
768 |
-
|
769 |
-
$locale =
|
770 |
-
}
|
771 |
-
if ($locale instanceof Zend_Locale) {
|
772 |
-
return $locale->toString();
|
773 |
-
}
|
774 |
-
if (!is_string($locale)) {
|
775 |
return false;
|
776 |
}
|
777 |
-
if (empty(self::$_auto)) {
|
778 |
-
$temp = new self($locale);
|
779 |
-
self::$_auto = $temp->getDefault(null, false);
|
780 |
-
self::$_browser = $temp->getDefault(self::BROWSER, false);
|
781 |
-
self::$_environment = $temp->getDefault(self::ENVIRONMENT, false);
|
782 |
-
}
|
783 |
-
if ($locale == 'auto') {
|
784 |
-
$locale = self::$_auto;
|
785 |
-
}
|
786 |
-
if ($locale == 'browser') {
|
787 |
-
$locale = self::$_browser;
|
788 |
-
}
|
789 |
-
if ($locale == 'environment') {
|
790 |
-
$locale = self::$_environment;
|
791 |
-
}
|
792 |
-
if (is_array($locale)) {
|
793 |
-
$locale = key($locale);
|
794 |
-
}
|
795 |
|
796 |
-
if (
|
797 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
798 |
} else {
|
799 |
-
$locale
|
800 |
-
|
801 |
-
|
|
|
|
|
|
|
|
|
802 |
}
|
803 |
}
|
|
|
804 |
return false;
|
805 |
}
|
806 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
|
808 |
/**
|
809 |
* Returns a list of all known locales where the locale is the key
|
810 |
* Only real locales are returned, the internal locales 'root', 'auto', 'browser'
|
811 |
* and 'environment' are suppressed
|
812 |
-
*
|
813 |
-
* @return
|
814 |
*/
|
815 |
public static function getLocaleList()
|
816 |
{
|
@@ -822,16 +815,152 @@ class Zend_Locale {
|
|
822 |
return $list;
|
823 |
}
|
824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
825 |
|
826 |
/**
|
827 |
* Sets a cache
|
828 |
*
|
829 |
-
* @param
|
|
|
830 |
*/
|
831 |
public static function setCache(Zend_Cache_Core $cache)
|
832 |
{
|
833 |
-
// load class within method for speed
|
834 |
#require_once 'Zend/Locale/Data.php';
|
835 |
Zend_Locale_Data::setCache($cache);
|
836 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
}
|
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_Locale
|
17 |
+
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
18 |
+
* @license http://framework.zend.com/license/new-bsd New BSD License
|
19 |
+
* @version $Id: Locale.php 13368 2008-12-19 10:48:07Z thomas $
|
20 |
*/
|
21 |
|
|
|
22 |
/**
|
23 |
+
* Base class for localization
|
24 |
+
*
|
25 |
+
* @category Zend
|
26 |
+
* @package Zend_Locale
|
27 |
+
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
28 |
+
* @license http://framework.zend.com/license/new-bsd New BSD License
|
29 |
*/
|
30 |
+
class Zend_Locale
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Class wide Locale Constants
|
34 |
+
*
|
35 |
+
* @var array $_localeData
|
36 |
+
*/
|
37 |
private static $_localeData = array(
|
38 |
+
'root' => true, 'aa_DJ' => true, 'aa_ER' => true, 'aa_ET' => true, 'aa' => true,
|
39 |
+
'af_NA' => true, 'af_ZA' => true, 'af' => true, 'ak_GH' => true, 'ak' => true,
|
40 |
+
'am_ET' => true, 'am' => true, 'ar_AE' => true, 'ar_BH' => true, 'ar_DZ' => true,
|
41 |
+
'ar_EG' => true, 'ar_IQ' => true, 'ar_JO' => true, 'ar_KW' => true, 'ar_LB' => true,
|
42 |
+
'ar_LY' => true, 'ar_MA' => true, 'ar_OM' => true, 'ar_QA' => true, 'ar_SA' => true,
|
43 |
+
'ar_SD' => true, 'ar_SY' => true, 'ar_TN' => true, 'ar_YE' => true, 'ar' => true,
|
44 |
+
'as_IN' => true, 'as' => true, 'az_AZ' => true, 'az' => true, 'be_BY' => true,
|
45 |
+
'be' => true, 'bg_BG' => true, 'bg' => true, 'bn_BD' => true, 'bn_IN' => true,
|
46 |
+
'bn' => true, 'bo_CN' => true, 'bo_IN' => true, 'bo' => true, 'bs_BA' => true,
|
47 |
+
'bs' => true, 'byn_ER'=> true, 'byn' => true, 'ca_ES' => true, 'ca' => true,
|
48 |
+
'cch_NG'=> true, 'cch' => true, 'cop_EG'=> true, 'cop_US'=> true, 'cop' => true,
|
49 |
+
'cs_CZ' => true, 'cs' => true, 'cy_GB' => true, 'cy' => true, 'da_DK' => true,
|
50 |
+
'da' => true, 'de_AT' => true, 'de_BE' => true, 'de_CH' => true, 'de_DE' => true,
|
51 |
+
'de_LI' => true, 'de_LU' => true, 'de' => true, 'dv_MV' => true, 'dv' => true,
|
52 |
+
'dz_BT' => true, 'dz' => true, 'ee_GH' => true, 'ee_TG' => true, 'ee' => true,
|
53 |
+
'el_CY' => true, 'el_GR' => true, 'el' => true, 'en_AS' => true, 'en_AU' => true,
|
54 |
+
'en_BE' => true, 'en_BW' => true, 'en_BZ' => true, 'en_CA' => true, 'en_GB' => true,
|
55 |
+
'en_GU' => true, 'en_HK' => true, 'en_IE' => true, 'en_IN' => true, 'en_JM' => true,
|
56 |
+
'en_MH' => true, 'en_MP' => true, 'en_MT' => true, 'en_NZ' => true, 'en_PH' => true,
|
57 |
+
'en_PK' => true, 'en_SG' => true, 'en_TT' => true, 'en_UM' => true, 'en_US' => true,
|
58 |
+
'en_VI' => true, 'en_ZA' => true, 'en_ZW' => true, 'en' => true, 'eo' => true,
|
59 |
+
'es_AR' => true, 'es_BO' => true, 'es_CL' => true, 'es_CO' => true, 'es_CR' => true,
|
60 |
+
'es_DO' => true, 'es_EC' => true, 'es_ES' => true, 'es_GT' => true, 'es_HN' => true,
|
61 |
+
'es_MX' => true, 'es_NI' => true, 'es_PA' => true, 'es_PE' => true, 'es_PR' => true,
|
62 |
+
'es_PY' => true, 'es_SV' => true, 'es_US' => true, 'es_UY' => true, 'es_VE' => true,
|
63 |
+
'es' => true, 'et_EE' => true, 'et' => true, 'eu_ES' => true, 'eu' => true,
|
64 |
+
'fa_AF' => true, 'fa_IR' => true, 'fa' => true, 'fi_FI' => true, 'fi' => true,
|
65 |
+
'fil' => true, 'fo_FO' => true, 'fo' => true, 'fr_BE' => true, 'fr_CA' => true,
|
66 |
+
'fr_CH' => true, 'fr_FR' => true, 'fr_LU' => true, 'fr_MC' => true, 'fr' => true,
|
67 |
+
'fur_IT'=> true, 'fur' => true, 'ga_IE' => true, 'ga' => true, 'gaa_GH'=> true,
|
68 |
+
'gaa' => true, 'gez_ER'=> true, 'gez_ET'=> true, 'gez' => true, 'gl_ES' => true,
|
69 |
+
'gl' => true, 'gu_IN' => true, 'gu' => true, 'gv_GB' => true, 'gv' => true,
|
70 |
+
'ha_GH' => true, 'ha_NE' => true, 'ha_NG' => true, 'ha' => true, 'haw_US'=> true,
|
71 |
+
'haw' => true, 'he_IL' => true, 'he' => true, 'hi_IN' => true, 'hi' => true,
|
72 |
+
'hr_HR' => true, 'hr' => true, 'hu_HU' => true, 'hu' => true, 'hy_AM' => true,
|
73 |
+
'hy' => true, 'ia' => true, 'id_ID' => true, 'id' => true, 'ig_NG' => true,
|
74 |
+
'ig' => true, 'ii_CN' => true, 'ii' => true, 'is_IS' => true, 'is' => true,
|
75 |
+
'it_CH' => true, 'it_IT' => true, 'it' => true, 'iu' => true, 'ja_JP' => true,
|
76 |
+
'ja' => true, 'ka_GE' => true, 'ka' => true, 'kaj_NG'=> true, 'kaj' => true,
|
77 |
+
'kam_KE'=> true, 'kam' => true, 'kcg_NG'=> true, 'kcg' => true, 'kfo_NG'=> true,
|
78 |
+
'kfo' => true, 'kk_KZ' => true, 'kk' => true, 'kl_GL' => true, 'kl' => true,
|
79 |
+
'km_KH' => true, 'km' => true, 'kn_IN' => true, 'kn' => true, 'ko_KR' => true,
|
80 |
+
'ko' => true, 'kok_IN'=> true, 'kok' => true, 'kpe_GN'=> true, 'kpe_LR'=> true,
|
81 |
+
'kpe' => true, 'ku_IQ' => true, 'ku_IR' => true, 'ku_SY' => true, 'ku_TR' => true,
|
82 |
+
'ku' => true, 'kw_GB' => true, 'kw' => true, 'ky_KG' => true, 'ky' => true,
|
83 |
+
'ln_CD' => true, 'ln_CG' => true, 'ln' => true, 'lo_LA' => true, 'lo' => true,
|
84 |
+
'lt_LT' => true, 'lt' => true, 'lv_LV' => true, 'lv' => true, 'mk_MK' => true,
|
85 |
+
'mk' => true, 'ml_IN' => true, 'ml' => true, 'mn_MN' => true, 'mn' => true,
|
86 |
+
'mr_IN' => true, 'mr' => true, 'ms_BN' => true, 'ms_MY' => true, 'ms' => true,
|
87 |
+
'mt_MT' => true, 'mt' => true, 'my_MM' => true, 'my' => true, 'nb_NO' => true,
|
88 |
+
'nb' => true, 'ne_NP' => true, 'ne' => true, 'nl_BE' => true, 'nl_NL' => true,
|
89 |
+
'nl' => true, 'nn_NO' => true, 'nn' => true, 'nr_ZA' => true, 'nr' => true,
|
90 |
+
'nso_ZA'=> true, 'nso' => true, 'ny_MW' => true, 'ny' => true, 'om_ET' => true,
|
91 |
+
'om_KE' => true, 'om' => true, 'or_IN' => true, 'or' => true, 'pa_IN' => true,
|
92 |
+
'pa_PK' => true, 'pa' => true, 'pl_PL' => true, 'pl' => true, 'ps_AF' => true,
|
93 |
+
'ps' => true, 'pt_BR' => true, 'pt_PT' => true, 'pt' => true, 'ro_RO' => true,
|
94 |
+
'ro' => true, 'ru_RU' => true, 'ru_UA' => true, 'ru' => true, 'rw_RW' => true,
|
95 |
+
'rw' => true, 'sa_IN' => true, 'sa' => true, 'se_FI' => true, 'se_NO' => true,
|
96 |
+
'se' => true, 'sh_BA' => true, 'sh_CS' => true, 'sh_YU' => true, 'sh' => true,
|
97 |
+
'sid_ET'=> true, 'sid' => true, 'sk_SK' => true, 'sk' => true, 'sl_SI' => true,
|
98 |
+
'sl' => true, 'so_DJ' => true, 'so_ET' => true, 'so_KE' => true, 'so_SO' => true,
|
99 |
+
'so' => true, 'sq_AL' => true, 'sq' => true, 'sr_BA' => true, 'sr_CS' => true,
|
100 |
+
'sr_ME' => true, 'sr_RS' => true, 'sr_YU' => true, 'sr' => true, 'ss_ZA' => true,
|
101 |
+
'ss' => true, 'ssy' => true, 'st_ZA' => true, 'st' => true, 'sv_FI' => true,
|
102 |
+
'sv_SE' => true, 'sv' => true, 'sw_KE' => true, 'sw_TZ' => true, 'sw' => true,
|
103 |
+
'syr_SY'=> true, 'syr' => true, 'ta_IN' => true, 'ta' => true, 'te_IN' => true,
|
104 |
+
'te' => true, 'tg_TJ' => true, 'tg' => true, 'th_TH' => true, 'th' => true,
|
105 |
+
'ti_ER' => true, 'ti_ET' => true, 'ti' => true, 'tig_ER'=> true, 'tig' => true,
|
106 |
+
'tn_ZA' => true, 'tn' => true, 'to_TO' => true, 'to' => true, 'tr_TR' => true,
|
107 |
+
'tr' => true, 'ts_ZA' => true, 'ts' => true, 'tt_RU' => true, 'tt' => true,
|
108 |
+
'ug' => true, 'uk_UA' => true, 'uk' => true, 'und_ZZ'=> true, 'und' => true,
|
109 |
+
'ur_IN' => true, 'ur_PK' => true, 'ur' => true, 'uz_AF' => true, 'uz_UZ' => true,
|
110 |
+
'uz' => true, 've_ZA' => true, 've' => true, 'vi_VN' => true, 'vi' => true,
|
111 |
+
'wal_ET'=> true, 'wal' => true, 'wo_SN' => true, 'wo' => true, 'xh_ZA' => true,
|
112 |
+
'xh' => true, 'yo_NG' => true, 'yo' => true, 'zh_CN' => true, 'zh_HK' => true,
|
113 |
+
'zh_MO' => true, 'zh_SG' => true, 'zh_TW' => true, 'zh' => true, 'zu_ZA' => true,
|
114 |
+
'zu' => true
|
115 |
);
|
116 |
|
|
|
117 |
/**
|
118 |
* Autosearch constants
|
119 |
*/
|
120 |
+
const BROWSER = 'browser';
|
121 |
+
const ENVIRONMENT = 'environment';
|
122 |
+
const ZFDEFAULT = 'default';
|
123 |
|
124 |
+
/**
|
125 |
+
* Defines if old behaviour should be supported
|
126 |
+
* Old behaviour throws notices and will be deleted in future releases
|
127 |
+
*
|
128 |
+
* @var boolean
|
129 |
+
*/
|
130 |
+
public static $compatibilityMode = true;
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Internal variable
|
134 |
+
*
|
135 |
+
* @var boolean
|
136 |
+
*/
|
137 |
+
private static $_breakChain = false;
|
138 |
|
139 |
/**
|
140 |
* Actual set locale
|
141 |
+
*
|
142 |
+
* @var string Locale
|
143 |
*/
|
144 |
+
protected $_locale;
|
145 |
|
146 |
+
/**
|
147 |
+
* Automatic detected locale
|
148 |
+
*
|
149 |
+
* @var string Locales
|
150 |
+
*/
|
151 |
+
protected static $_auto;
|
152 |
|
153 |
/**
|
154 |
+
* Browser detected locale
|
155 |
+
*
|
156 |
+
* @var string Locales
|
157 |
*/
|
158 |
+
protected static $_browser;
|
159 |
|
160 |
/**
|
161 |
+
* Environment detected locale
|
162 |
+
*
|
163 |
+
* @var string Locales
|
164 |
*/
|
165 |
+
protected static $_environment;
|
|
|
|
|
166 |
|
167 |
+
/**
|
168 |
+
* Default locale
|
169 |
+
*
|
170 |
+
* @var string Locales
|
171 |
+
*/
|
172 |
+
protected static $_default = array('en' => true);
|
173 |
|
174 |
/**
|
175 |
* Generates a locale object
|
181 |
* 3. Server Environment
|
182 |
* 4. Framework Standard
|
183 |
*
|
184 |
+
* @param string|Zend_Locale $locale (Optional) Locale for parsing input
|
185 |
+
* @throws Zend_Locale_Exception When autodetection has been failed
|
186 |
*/
|
187 |
public function __construct($locale = null)
|
188 |
{
|
189 |
+
$locale = self::_prepareLocale($locale);
|
190 |
+
$this->setLocale((string) $locale);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
|
|
|
193 |
/**
|
194 |
* Serialization Interface
|
195 |
*
|
200 |
return serialize($this);
|
201 |
}
|
202 |
|
|
|
203 |
/**
|
204 |
* Returns a string representation of the object
|
205 |
*
|
207 |
*/
|
208 |
public function toString()
|
209 |
{
|
210 |
+
return (string) $this->_locale;
|
211 |
}
|
212 |
|
|
|
213 |
/**
|
214 |
* Returns a string representation of the object
|
215 |
* Alias for toString
|
221 |
return $this->toString();
|
222 |
}
|
223 |
|
|
|
224 |
/**
|
225 |
+
* Return the default locale
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
*
|
227 |
+
* @return array Returns an array of all locale string
|
|
|
|
|
|
|
228 |
*/
|
229 |
+
public static function getDefault()
|
230 |
{
|
231 |
+
if ((self::$compatibilityMode === true) or (func_num_args() > 0)) {
|
232 |
+
if (!self::$_breakChain) {
|
233 |
+
self::$_breakChain = true;
|
234 |
+
trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
|
235 |
+
$params = func_get_args();
|
236 |
+
$param = null;
|
237 |
+
if (isset($params[0])) {
|
238 |
+
$param = $params[0];
|
239 |
+
}
|
240 |
+
return self::getOrder($param);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
}
|
242 |
|
243 |
+
self::$_breakChain = false;
|
244 |
}
|
245 |
|
246 |
+
return self::$_default;
|
|
|
|
|
|
|
247 |
}
|
248 |
|
|
|
249 |
/**
|
250 |
* Sets a new default locale
|
251 |
+
* If provided you can set a quality between 0 and 1 (or 2 and 100)
|
252 |
+
* which represents the percent of quality the browser
|
253 |
+
* requested within HTTP
|
254 |
*
|
255 |
+
* @param string|Zend_Locale $locale Locale to set
|
256 |
+
* @param float $quality The quality to set from 0 to 1
|
257 |
+
* @throws Zend_Locale_Exception When a autolocale was given
|
258 |
+
* @throws Zend_Locale_Exception When a unknown locale was given
|
259 |
+
* @return void
|
260 |
*/
|
261 |
+
public static function setDefault($locale, $quality = 1)
|
262 |
{
|
263 |
+
if (($locale === 'auto') or ($locale === 'root') or ($locale === 'default') or
|
264 |
+
($locale === 'environment') or ($locale === 'browser')) {
|
265 |
#require_once 'Zend/Locale/Exception.php';
|
266 |
throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
|
267 |
}
|
268 |
+
|
269 |
+
if (($quality < 0.1) or ($quality > 100)) {
|
270 |
+
#require_once 'Zend/Locale/Exception.php';
|
271 |
+
throw new Zend_Locale_Exception("Quality must be between 0.1 and 100");
|
272 |
+
}
|
273 |
+
|
274 |
+
if ($quality > 1) {
|
275 |
+
$quality /= 100;
|
276 |
+
}
|
277 |
+
|
278 |
+
if (isset(self::$_localeData[(string) $locale]) === true) {
|
279 |
+
self::$_default = array((string) $locale => $quality);
|
280 |
} else {
|
281 |
+
$locale = explode('_', (string) $locale);
|
282 |
+
if (isset(self::$_localeData[$locale[0]]) === true) {
|
283 |
+
self::$_default = array($locale[0] => $quality);
|
284 |
+
} else {
|
285 |
+
#require_once 'Zend/Locale/Exception.php';
|
286 |
+
throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
|
287 |
}
|
288 |
}
|
|
|
|
|
289 |
}
|
290 |
|
|
|
291 |
/**
|
292 |
* Expects the Systems standard locale
|
293 |
*
|
297 |
*
|
298 |
* @return array
|
299 |
*/
|
300 |
+
public static function getEnvironment()
|
301 |
{
|
302 |
+
if (self::$_environment !== null) {
|
303 |
+
return self::$_environment;
|
304 |
+
}
|
305 |
|
306 |
+
#require_once 'Zend/Locale/Data/Translation.php';
|
|
|
307 |
|
308 |
+
$language = setlocale(LC_ALL, 0);
|
309 |
+
$languages = explode(';', $language);
|
310 |
$languagearray = array();
|
311 |
|
312 |
foreach ($languages as $locale) {
|
|
|
313 |
if (strpos($locale, '=') !== false) {
|
314 |
$language = substr($locale, strpos($locale, '='));
|
315 |
$language = substr($language, 1);
|
316 |
}
|
317 |
|
318 |
+
if ($language !== 'C') {
|
319 |
if (strpos($language, '.') !== false) {
|
320 |
+
$language = substr($language, 0, (strpos($language, '.') - 1));
|
321 |
} else if (strpos($language, '@') !== false) {
|
322 |
+
$language = substr($language, 0, (strpos($language, '@') - 1));
|
323 |
}
|
324 |
+
|
325 |
$splitted = explode('_', $language);
|
326 |
+
$language = (string) $language;
|
327 |
+
if (isset(self::$_localeData[$language]) === true) {
|
328 |
$languagearray[$language] = 1;
|
329 |
if (strlen($language) > 4) {
|
330 |
$languagearray[substr($language, 0, 2)] = 1;
|
331 |
}
|
332 |
+
|
333 |
continue;
|
334 |
}
|
335 |
|
336 |
+
if (empty(Zend_Locale_Data_Translation::$localeTranslation[$splitted[0]]) === false) {
|
337 |
+
if (empty(Zend_Locale_Data_Translation::$localeTranslation[$splitted[1]]) === false) {
|
338 |
+
$languagearray[Zend_Locale_Data_Translation::$localeTranslation[$splitted[0]] . '_' .
|
339 |
+
Zend_Locale_Data_Translation::$localeTranslation[$splitted[1]]] = 1;
|
340 |
}
|
341 |
+
|
342 |
$languagearray[Zend_Locale_Data_Translation::$localeTranslation[$splitted[0]]] = 1;
|
343 |
}
|
344 |
}
|
345 |
}
|
346 |
+
|
347 |
+
self::$_environment = $languagearray;
|
348 |
return $languagearray;
|
349 |
}
|
350 |
|
357 |
*
|
358 |
* @return array - list of accepted languages including quality
|
359 |
*/
|
360 |
+
public static function getBrowser()
|
361 |
{
|
362 |
+
if (self::$_browser !== null) {
|
363 |
+
return self::$_browser;
|
364 |
+
}
|
365 |
|
366 |
+
$httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
|
367 |
+
$languages = array();
|
368 |
+
if (empty($httplanguages) === true) {
|
369 |
return $languages;
|
370 |
}
|
371 |
|
372 |
$accepted = preg_split('/,\s*/', $httplanguages);
|
373 |
|
374 |
foreach ($accepted as $accept) {
|
375 |
+
$match = null;
|
376 |
$result = preg_match('/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
|
377 |
$accept, $match);
|
378 |
|
379 |
+
if ($result < 1) {
|
380 |
continue;
|
381 |
}
|
382 |
|
383 |
+
if (isset($match[2]) === true) {
|
384 |
$quality = (float) $match[2];
|
385 |
} else {
|
386 |
$quality = 1.0;
|
387 |
}
|
388 |
|
389 |
$countrys = explode('-', $match[1]);
|
390 |
+
$region = array_shift($countrys);
|
391 |
|
392 |
$country2 = explode('_', $region);
|
393 |
+
$region = array_shift($country2);
|
394 |
|
395 |
+
foreach ($countrys as $country) {
|
396 |
$languages[$region . '_' . strtoupper($country)] = $quality;
|
397 |
}
|
398 |
+
|
399 |
+
foreach ($country2 as $country) {
|
400 |
$languages[$region . '_' . strtoupper($country)] = $quality;
|
401 |
}
|
402 |
+
|
403 |
+
if ((isset($languages[$region]) === false) || ($languages[$region] < $quality)) {
|
404 |
$languages[$region] = $quality;
|
405 |
}
|
406 |
}
|
|
|
|
|
407 |
|
408 |
+
self::$_browser = $languages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
return $languages;
|
410 |
}
|
411 |
|
|
|
412 |
/**
|
413 |
* Sets a new locale
|
414 |
*
|
415 |
+
* @param string|Zend_Locale $locale (Optional) New locale to set
|
416 |
+
* @return void
|
417 |
*/
|
418 |
public function setLocale($locale = null)
|
419 |
{
|
420 |
+
$locale = self::_prepareLocale($locale);
|
|
|
|
|
421 |
|
422 |
+
if (isset(self::$_localeData[(string) $locale]) === false) {
|
423 |
+
$region = substr((string) $locale, 0, 3);
|
424 |
+
if (isset($region[2]) === true) {
|
425 |
+
if (($region[2] === '_') or ($region[2] === '-')) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
$region = substr($region, 0, 2);
|
427 |
}
|
428 |
}
|
429 |
+
|
430 |
+
if (isset(self::$_localeData[(string) $region]) === true) {
|
431 |
+
$this->_locale = $region;
|
432 |
} else {
|
433 |
+
$this->_locale = 'root';
|
434 |
}
|
|
|
435 |
} else {
|
436 |
+
$this->_locale = $locale;
|
437 |
}
|
438 |
}
|
439 |
|
|
|
440 |
/**
|
441 |
* Returns the language part of the locale
|
442 |
*
|
444 |
*/
|
445 |
public function getLanguage()
|
446 |
{
|
447 |
+
$locale = explode('_', $this->_locale);
|
448 |
return $locale[0];
|
449 |
}
|
450 |
|
|
|
451 |
/**
|
452 |
* Returns the region part of the locale if available
|
453 |
*
|
455 |
*/
|
456 |
public function getRegion()
|
457 |
{
|
458 |
+
$locale = explode('_', $this->_locale);
|
459 |
+
if (isset($locale[1]) === true) {
|
460 |
return $locale[1];
|
461 |
}
|
462 |
|
463 |
return false;
|
464 |
}
|
465 |
|
|
|
466 |
/**
|
467 |
* Return the accepted charset of the client
|
468 |
+
*
|
469 |
* @return string
|
470 |
*/
|
471 |
+
public static function getHttpCharset()
|
472 |
{
|
473 |
+
$httpcharsets = getenv('HTTP_ACCEPT_CHARSET');
|
474 |
|
475 |
$charsets = array();
|
476 |
if ($httpcharsets === false) {
|
478 |
}
|
479 |
|
480 |
$accepted = preg_split('/,\s*/', $httpcharsets);
|
481 |
+
foreach ($accepted as $accept) {
|
482 |
+
if (empty($accept) === true) {
|
|
|
483 |
continue;
|
484 |
}
|
485 |
|
486 |
+
if (strpos($accept, ';') !== false) {
|
487 |
+
$quality = (float) substr($accept, (strpos($accept, '=') + 1));
|
488 |
+
$pos = substr($accept, 0, strpos($accept, ';'));
|
489 |
+
$charsets[$pos] = $quality;
|
490 |
} else {
|
491 |
+
$quality = 1.0;
|
492 |
$charsets[$accept] = $quality;
|
493 |
}
|
|
|
494 |
}
|
495 |
|
496 |
return $charsets;
|
497 |
}
|
498 |
|
|
|
499 |
/**
|
500 |
* Returns true if both locales are equal
|
501 |
*
|
502 |
+
* @param Zend_Locale $object Locale to check for equality
|
503 |
* @return boolean
|
504 |
*/
|
505 |
+
public function equals(Zend_Locale $object)
|
506 |
{
|
507 |
+
if ($object->toString() === $this->toString()) {
|
508 |
return true;
|
509 |
}
|
510 |
|
511 |
return false;
|
512 |
}
|
513 |
|
|
|
514 |
/**
|
515 |
* Returns localized informations as array, supported are several
|
516 |
* types of informations.
|
517 |
* For detailed information about the types look into the documentation
|
518 |
*
|
519 |
+
* @param string $path (Optional) Type of information to return
|
520 |
+
* @param string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
|
521 |
+
* @param string $value (Optional) Value for detail list
|
522 |
+
* @return array Array with the wished information in the given language
|
523 |
*/
|
524 |
+
public static function getTranslationList($path = null, $locale = null, $value = null)
|
525 |
{
|
|
|
526 |
#require_once 'Zend/Locale/Data.php';
|
527 |
+
$locale = self::_prepareLocale($locale);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
$result = Zend_Locale_Data::getList($locale, $path, $value);
|
529 |
+
if (empty($result) === true) {
|
530 |
return false;
|
531 |
}
|
532 |
+
|
533 |
return $result;
|
534 |
}
|
535 |
|
|
|
536 |
/**
|
537 |
* Returns an array with the name of all languages translated to the given language
|
538 |
*
|
539 |
+
* @param string|Zend_Locale $locale (Optional) Locale for language translation
|
540 |
+
* @return array
|
541 |
*/
|
542 |
+
public static function getLanguageTranslationList($locale = null)
|
543 |
{
|
544 |
+
return self::getTranslationList('language', $locale);
|
545 |
}
|
546 |
|
|
|
547 |
/**
|
548 |
* Returns an array with the name of all scripts translated to the given language
|
549 |
*
|
550 |
+
* @param string|Zend_Locale $locale (Optional) Locale for script translation
|
551 |
+
* @return array
|
552 |
*/
|
553 |
+
public static function getScriptTranslationList($locale = null)
|
554 |
{
|
555 |
+
return self::getTranslationList('script', $locale);
|
556 |
}
|
557 |
|
|
|
558 |
/**
|
559 |
* Returns an array with the name of all countries translated to the given language
|
560 |
*
|
561 |
+
* @param string|Zend_Locale $locale (Optional) Locale for country translation
|
562 |
+
* @return array
|
563 |
*/
|
564 |
+
public static function getCountryTranslationList($locale = null)
|
565 |
{
|
566 |
+
return self::getTranslationList('territory', $locale, 2);
|
567 |
}
|
568 |
|
|
|
569 |
/**
|
570 |
* Returns an array with the name of all territories translated to the given language
|
571 |
* All territories contains other countries.
|
572 |
*
|
573 |
+
* @param string|Zend_Locale $locale (Optional) Locale for territory translation
|
574 |
+
* @return array
|
575 |
*/
|
576 |
+
public static function getTerritoryTranslationList($locale = null)
|
577 |
{
|
578 |
+
return self::getTranslationList('territory', $locale, 1);
|
579 |
}
|
580 |
|
|
|
581 |
/**
|
582 |
* Returns a localized information string, supported are several types of informations.
|
583 |
* For detailed information about the types look into the documentation
|
584 |
*
|
585 |
+
* @param string $value Name to get detailed information about
|
586 |
+
* @param string $path (Optional) Type of information to return
|
587 |
+
* @param string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
|
588 |
+
* @return string|false The wished information in the given language
|
589 |
*/
|
590 |
+
public static function getTranslation($value = null, $path = null, $locale = null)
|
591 |
{
|
|
|
592 |
#require_once 'Zend/Locale/Data.php';
|
593 |
+
$locale = self::_prepareLocale($locale);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
$result = Zend_Locale_Data::getContent($locale, $path, $value);
|
595 |
+
if (empty($result) === true) {
|
596 |
return false;
|
597 |
}
|
598 |
+
|
599 |
return $result;
|
600 |
}
|
601 |
|
|
|
602 |
/**
|
603 |
* Returns the localized language name
|
604 |
*
|
605 |
+
* @param string $value Name to get detailed information about
|
606 |
+
* @param string $locale (Optional) Locale for language translation
|
607 |
+
* @return array
|
608 |
*/
|
609 |
+
public static function getLanguageTranslation($value, $locale = null)
|
610 |
{
|
611 |
+
return self::getTranslation($value, 'language', $locale);
|
612 |
}
|
613 |
|
|
|
614 |
/**
|
615 |
* Returns the localized script name
|
616 |
*
|
617 |
+
* @param string $value Name to get detailed information about
|
618 |
+
* @param string $locale (Optional) locale for script translation
|
619 |
+
* @return array
|
620 |
*/
|
621 |
+
public static function getScriptTranslation($value, $locale = null)
|
622 |
{
|
623 |
+
return self::getTranslation($value, 'script', $locale);
|
624 |
}
|
625 |
|
|
|
626 |
/**
|
627 |
* Returns the localized country name
|
628 |
*
|
629 |
+
* @param string $value Name to get detailed information about
|
630 |
+
* @param string|Zend_Locale $locale (Optional) Locale for country translation
|
631 |
+
* @return array
|
632 |
*/
|
633 |
+
public static function getCountryTranslation($value, $locale = null)
|
634 |
{
|
635 |
+
return self::getTranslation($value, 'country', $locale);
|
636 |
}
|
637 |
|
|
|
638 |
/**
|
639 |
* Returns the localized territory name
|
640 |
* All territories contains other countries.
|
641 |
*
|
642 |
+
* @param string $value Name to get detailed information about
|
643 |
+
* @param string|Zend_Locale $locale (Optional) Locale for territory translation
|
644 |
+
* @return array
|
645 |
*/
|
646 |
+
public static function getTerritoryTranslation($value, $locale = null)
|
647 |
{
|
648 |
+
return self::getTranslation($value, 'territory', $locale);
|
649 |
}
|
650 |
|
|
|
651 |
/**
|
652 |
* Returns an array with translated yes strings
|
653 |
*
|
654 |
+
* @param string|Zend_Locale $locale (Optional) Locale for language translation (defaults to $this locale)
|
655 |
* @return array
|
656 |
*/
|
657 |
+
public static function getQuestion($locale = null)
|
658 |
{
|
|
|
659 |
#require_once 'Zend/Locale/Data.php';
|
660 |
+
$locale = self::_prepareLocale($locale);
|
661 |
+
$quest = Zend_Locale_Data::getList($locale, 'question');
|
662 |
+
$yes = explode(':', $quest['yes']);
|
663 |
+
$no = explode(':', $quest['no']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
$quest['yes'] = $yes[0];
|
665 |
$quest['yesarray'] = $yes;
|
666 |
$quest['no'] = $no[0];
|
667 |
$quest['noarray'] = $no;
|
668 |
+
$quest['yesexpr'] = self::_prepareQuestionString($yes);
|
669 |
+
$quest['noexpr'] = self::_prepareQuestionString($no);
|
670 |
|
671 |
return $quest;
|
672 |
}
|
673 |
|
|
|
674 |
/**
|
675 |
+
* Internal function for preparing the returned question regex string
|
676 |
*
|
677 |
+
* @param string $input Regex to parse
|
678 |
* @return string
|
679 |
*/
|
680 |
+
private static function _prepareQuestionString($input)
|
681 |
{
|
682 |
+
$regex = '';
|
683 |
+
if (is_array($input) === true) {
|
684 |
+
$regex = '^';
|
685 |
$start = true;
|
686 |
+
foreach ($input as $row) {
|
687 |
if ($start === false) {
|
688 |
+
$regex .= '|';
|
689 |
}
|
690 |
+
|
691 |
+
$start = false;
|
692 |
+
$regex .= '(';
|
693 |
+
$one = null;
|
694 |
if (strlen($row) > 2) {
|
695 |
$one = true;
|
696 |
}
|
697 |
+
|
698 |
foreach (str_split($row, 1) as $char) {
|
699 |
+
$regex .= '[' . $char;
|
700 |
+
$regex .= strtoupper($char) . ']';
|
701 |
if ($one === true) {
|
702 |
+
$one = false;
|
703 |
+
$regex .= '(';
|
704 |
}
|
705 |
}
|
706 |
+
|
707 |
if ($one === false) {
|
708 |
+
$regex .= ')';
|
709 |
}
|
710 |
+
|
711 |
+
$regex .= '?)';
|
712 |
}
|
713 |
}
|
714 |
+
|
715 |
return $regex;
|
716 |
}
|
717 |
|
|
|
718 |
/**
|
719 |
* Checks if a locale identifier is a real locale or not
|
720 |
* Examples:
|
721 |
* "en_XX" refers to "en", which returns true
|
722 |
* "XX_yy" refers to "root", which returns false
|
723 |
*
|
724 |
+
* @param string|Zend_Locale $locale Locale to check for
|
725 |
+
* @param boolean $strict (Optional) If true, no rerouting will be done when checking
|
726 |
+
* @param boolean $compatible (DEPRECIATED) Only for internal usage, brakes compatibility mode
|
727 |
+
* @return boolean If the locale is known dependend on the settings
|
728 |
*/
|
729 |
+
public static function isLocale($locale, $strict = false, $compatible = true)
|
730 |
{
|
731 |
+
try {
|
732 |
+
$locale = self::_prepareLocale($locale, $strict);
|
733 |
+
} catch (Zend_Locale_Exception $e) {
|
|
|
|
|
|
|
|
|
734 |
return false;
|
735 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
736 |
|
737 |
+
if (($compatible === true) and (self::$compatibilityMode === true)) {
|
738 |
+
trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
|
739 |
+
if (isset(self::$_localeData[$locale]) === true) {
|
740 |
+
return $locale;
|
741 |
+
} else if (!$strict) {
|
742 |
+
$locale = explode('_', $locale);
|
743 |
+
if (isset(self::$_localeData[$locale[0]]) === true) {
|
744 |
+
return $locale[0];
|
745 |
+
}
|
746 |
+
}
|
747 |
} else {
|
748 |
+
if (isset(self::$_localeData[$locale]) === true) {
|
749 |
+
return true;
|
750 |
+
} else if (!$strict) {
|
751 |
+
$locale = explode('_', $locale);
|
752 |
+
if (isset(self::$_localeData[$locale[0]]) === true) {
|
753 |
+
return true;
|
754 |
+
}
|
755 |
}
|
756 |
}
|
757 |
+
|
758 |
return false;
|
759 |
}
|
760 |
|
761 |
+
/**
|
762 |
+
* Finds the proper locale based on the input
|
763 |
+
* Checks if it exists, degrades it when necessary
|
764 |
+
* Detects registry locale and when all fails tries to detect a automatic locale
|
765 |
+
* Returns the found locale as string
|
766 |
+
*
|
767 |
+
* @param string $locale
|
768 |
+
* @throws Zend_Locale_Exception When the given locale is no locale or the autodetection fails
|
769 |
+
* @return string
|
770 |
+
*/
|
771 |
+
public static function findLocale($locale = null)
|
772 |
+
{
|
773 |
+
if ($locale === null) {
|
774 |
+
#require_once 'Zend/Registry.php';
|
775 |
+
if (Zend_Registry::isRegistered('Zend_Locale')) {
|
776 |
+
$locale = Zend_Registry::get('Zend_Locale');
|
777 |
+
}
|
778 |
+
}
|
779 |
+
|
780 |
+
#require_once 'Zend/Locale.php';
|
781 |
+
if ($locale === null) {
|
782 |
+
$locale = new Zend_Locale();
|
783 |
+
}
|
784 |
+
|
785 |
+
if (!Zend_Locale::isLocale($locale, true, false)) {
|
786 |
+
if (!Zend_Locale::isLocale($locale, false, false)) {
|
787 |
+
#require_once 'Zend/Locale/Exception.php';
|
788 |
+
throw new Zend_Locale_Exception("The locale '$locale' is no known locale");
|
789 |
+
}
|
790 |
+
|
791 |
+
$locale = new Zend_Locale($locale);
|
792 |
+
}
|
793 |
+
|
794 |
+
if ($locale instanceof Zend_Locale) {
|
795 |
+
$locale = $locale->toString();
|
796 |
+
}
|
797 |
+
|
798 |
+
return $locale;
|
799 |
+
}
|
800 |
|
801 |
/**
|
802 |
* Returns a list of all known locales where the locale is the key
|
803 |
* Only real locales are returned, the internal locales 'root', 'auto', 'browser'
|
804 |
* and 'environment' are suppressed
|
805 |
+
*
|
806 |
+
* @return array List of all Locales
|
807 |
*/
|
808 |
public static function getLocaleList()
|
809 |
{
|
815 |
return $list;
|
816 |
}
|
817 |
|
818 |
+
/**
|
819 |
+
* Returns the set cache
|
820 |
+
*
|
821 |
+
* @return Zend_Cache_Core The set cache
|
822 |
+
*/
|
823 |
+
public static function getCache()
|
824 |
+
{
|
825 |
+
#require_once 'Zend/Locale/Data.php';
|
826 |
+
$cache = Zend_Locale_Data::getCache();
|
827 |
+
|
828 |
+
return $cache;
|
829 |
+
}
|
830 |
|
831 |
/**
|
832 |
* Sets a cache
|
833 |
*
|
834 |
+
* @param Zend_Cache_Core $cache Cache to set
|
835 |
+
* @return void
|
836 |
*/
|
837 |
public static function setCache(Zend_Cache_Core $cache)
|
838 |
{
|
|
|
839 |
#require_once 'Zend/Locale/Data.php';
|
840 |
Zend_Locale_Data::setCache($cache);
|
841 |
}
|
842 |
+
|
843 |
+
/**
|
844 |
+
* Returns true when a cache is set
|
845 |
+
*
|
846 |
+
* @return boolean
|
847 |
+
*/
|
848 |
+
public static function hasCache()
|
849 |
+
{
|
850 |
+
#require_once 'Zend/Locale/Data.php';
|
851 |
+
return Zend_Locale_Data::hasCache();
|
852 |
+
}
|
853 |
+
|
854 |
+
/**
|
855 |
+
* Removes any set cache
|
856 |
+
*
|
857 |
+
* @return void
|
858 |
+
*/
|
859 |
+
public static function removeCache()
|
860 |
+
{
|
861 |
+
#require_once 'Zend/Locale/Data.php';
|
862 |
+
Zend_Locale_Data::removeCache();
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Clears all set cache data
|
867 |
+
*
|
868 |
+
* @return void
|
869 |
+
*/
|
870 |
+
public static function clearCache()
|
871 |
+
{
|
872 |
+
#require_once 'Zend/Locale/Data.php';
|
873 |
+
Zend_Locale_Data::clearCache();
|
874 |
+
}
|
875 |
+
|
876 |
+
/**
|
877 |
+
* Internal function, returns a single locale on detection
|
878 |
+
*
|
879 |
+
* @param string|Zend_Locale $locale (Optional) Locale to work on
|
880 |
+
* @param boolean $strict (Optional) Strict preparation
|
881 |
+
* @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended
|
882 |
+
* @return string
|
883 |
+
*/
|
884 |
+
private static function _prepareLocale($locale, $strict = false)
|
885 |
+
{
|
886 |
+
if ($locale instanceof Zend_Locale) {
|
887 |
+
$locale = $locale->toString();
|
888 |
+
}
|
889 |
+
|
890 |
+
if (is_array($locale)) {
|
891 |
+
return '';
|
892 |
+
}
|
893 |
+
|
894 |
+
if (empty(self::$_auto) === true) {
|
895 |
+
self::$_browser = self::getBrowser();
|
896 |
+
self::$_environment = self::getEnvironment();
|
897 |
+
self::$_breakChain = true;
|
898 |
+
self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
|
899 |
+
}
|
900 |
+
|
901 |
+
if (!$strict) {
|
902 |
+
if ($locale === 'browser') {
|
903 |
+
$locale = self::$_browser;
|
904 |
+
}
|
905 |
+
|
906 |
+
if ($locale === 'environment') {
|
907 |
+
$locale = self::$_environment;
|
908 |
+
}
|
909 |
+
|
910 |
+
if ($locale === 'default') {
|
911 |
+
$locale = self::$_default;
|
912 |
+
}
|
913 |
+
|
914 |
+
if (($locale === 'auto') or ($locale === null)) {
|
915 |
+
$locale = self::$_auto;
|
916 |
+
}
|
917 |
+
|
918 |
+
if (is_array($locale) === true) {
|
919 |
+
$locale = key($locale);
|
920 |
+
}
|
921 |
+
}
|
922 |
+
|
923 |
+
// This can only happen when someone extends Zend_Locale and erases the default
|
924 |
+
if ($locale === null) {
|
925 |
+
#require_once 'Zend/Locale/Exception.php';
|
926 |
+
throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
|
927 |
+
}
|
928 |
+
|
929 |
+
if (strpos($locale, '-') !== false) {
|
930 |
+
$locale = strtr($locale, '-', '_');
|
931 |
+
}
|
932 |
+
|
933 |
+
return (string) $locale;
|
934 |
+
}
|
935 |
+
|
936 |
+
/**
|
937 |
+
* Search the locale automatically and return all used locales
|
938 |
+
* ordered by quality
|
939 |
+
*
|
940 |
+
* Standard Searchorder is Browser, Environment, Default
|
941 |
+
*
|
942 |
+
* @param string $searchorder (Optional) Searchorder
|
943 |
+
* @return array Returns an array of all detected locales
|
944 |
+
*/
|
945 |
+
public static function getOrder($order = null)
|
946 |
+
{
|
947 |
+
switch ($order) {
|
948 |
+
case self::ENVIRONMENT:
|
949 |
+
self::$_breakChain = true;
|
950 |
+
$languages = self::getEnvironment() + self::getBrowser() + self::getDefault();
|
951 |
+
break;
|
952 |
+
|
953 |
+
case self::ZFDEFAULT:
|
954 |
+
self::$_breakChain = true;
|
955 |
+
$languages = self::getDefault() + self::getEnvironment() + self::getBrowser();
|
956 |
+
break;
|
957 |
+
|
958 |
+
default:
|
959 |
+
self::$_breakChain = true;
|
960 |
+
$languages = self::getBrowser() + self::getEnvironment() + self::getDefault();
|
961 |
+
break;
|
962 |
+
}
|
963 |
+
|
964 |
+
return $languages;
|
965 |
+
}
|
966 |
}
|
lib/Zend/Locale/Data.php
CHANGED
@@ -16,18 +16,18 @@
|
|
16 |
* @package Zend_Locale
|
17 |
* @subpackage Data
|
18 |
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
19 |
-
* @version $Id: Data.php 8064 2008-02-16 10:58:39Z thomas $
|
20 |
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
21 |
*/
|
22 |
|
23 |
-
|
24 |
/**
|
25 |
* include needed classes
|
26 |
*/
|
27 |
#require_once 'Zend/Locale.php';
|
28 |
|
29 |
-
|
30 |
/**
|
|
|
|
|
31 |
* @category Zend
|
32 |
* @package Zend_Locale
|
33 |
* @subpackage Data
|
@@ -37,32 +37,29 @@
|
|
37 |
class Zend_Locale_Data
|
38 |
{
|
39 |
/**
|
40 |
-
*
|
41 |
*
|
42 |
* @var ressource
|
43 |
* @access private
|
44 |
*/
|
45 |
private static $_ldml = array();
|
46 |
|
47 |
-
|
48 |
/**
|
49 |
-
*
|
50 |
*
|
51 |
* @var array
|
52 |
* @access private
|
53 |
*/
|
54 |
private static $_list = array();
|
55 |
|
56 |
-
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
* @var Zend_Cache_Core
|
61 |
* @access private
|
62 |
*/
|
63 |
private static $_cache = null;
|
64 |
|
65 |
-
|
66 |
/**
|
67 |
* Read the content from locale
|
68 |
*
|
@@ -274,15 +271,12 @@ class Zend_Locale_Data
|
|
274 |
$locale = new Zend_Locale();
|
275 |
}
|
276 |
|
277 |
-
if ($locale
|
278 |
-
$locale = $locale->toString();
|
279 |
-
}
|
280 |
-
|
281 |
-
if (!($locale = Zend_Locale::isLocale($locale))) {
|
282 |
#require_once 'Zend/Locale/Exception.php';
|
283 |
-
throw new Zend_Locale_Exception("Locale ($locale) is a unknown locale");
|
284 |
}
|
285 |
-
|
|
|
286 |
}
|
287 |
|
288 |
/**
|
@@ -297,12 +291,12 @@ class Zend_Locale_Data
|
|
297 |
public static function getList($locale, $path, $value = false)
|
298 |
{
|
299 |
$locale = self::_checkLocale($locale);
|
300 |
-
|
301 |
if (isset(self::$_cache)) {
|
302 |
$val = $value;
|
303 |
if (is_array($value)) {
|
304 |
$val = implode('_' , $value);
|
305 |
}
|
|
|
306 |
$val = urlencode($val);
|
307 |
$id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
|
308 |
if ($result = self::$_cache->load($id)) {
|
@@ -324,13 +318,13 @@ class Zend_Locale_Data
|
|
324 |
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
|
325 |
if ($value === 1) {
|
326 |
foreach($temp as $key => $value) {
|
327 |
-
if (
|
328 |
unset($temp[$key]);
|
329 |
}
|
330 |
}
|
331 |
} else if ($value === 2) {
|
332 |
foreach($temp as $key => $value) {
|
333 |
-
if (is_numeric($key)) {
|
334 |
unset($temp[$key]);
|
335 |
}
|
336 |
}
|
@@ -558,8 +552,9 @@ class Zend_Locale_Data
|
|
558 |
foreach ($_temp as $key => $keyvalue) {
|
559 |
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
|
560 |
if (!isset($val[$key])) {
|
561 |
-
|
562 |
-
}
|
|
|
563 |
$temp[$val[$key]] = $key;
|
564 |
} else {
|
565 |
$temp[$val[$key]] .= " " . $key;
|
@@ -605,8 +600,9 @@ class Zend_Locale_Data
|
|
605 |
foreach ($_temp as $key => $keyvalue) {
|
606 |
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
|
607 |
if (!isset($val[$key])) {
|
608 |
-
|
609 |
-
}
|
|
|
610 |
$temp[$val[$key]] = $key;
|
611 |
} else {
|
612 |
$temp[$val[$key]] .= " " . $key;
|
@@ -630,7 +626,7 @@ class Zend_Locale_Data
|
|
630 |
foreach($_temp as $key => $found) {
|
631 |
$_temp3 = explode(" ", $found);
|
632 |
foreach($_temp3 as $found3) {
|
633 |
-
if (!
|
634 |
$temp[$found3] = (string) $key;
|
635 |
} else {
|
636 |
$temp[$found3] .= " " . $key;
|
@@ -661,7 +657,7 @@ class Zend_Locale_Data
|
|
661 |
if (empty($found3)) {
|
662 |
continue;
|
663 |
}
|
664 |
-
if (!
|
665 |
$temp[$found3] = (string) $key;
|
666 |
} else {
|
667 |
$temp[$found3] .= " " . $key;
|
@@ -692,7 +688,7 @@ class Zend_Locale_Data
|
|
692 |
if (empty($found3)) {
|
693 |
continue;
|
694 |
}
|
695 |
-
if (!
|
696 |
$temp[$found3] = (string) $key;
|
697 |
} else {
|
698 |
$temp[$found3] .= " " . $key;
|
@@ -975,10 +971,10 @@ class Zend_Locale_Data
|
|
975 |
$temp = array();
|
976 |
foreach ($_temp as $key => $keyvalue) {
|
977 |
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
|
978 |
-
if (!isset($val[$key])
|
979 |
continue;
|
980 |
}
|
981 |
-
if (!
|
982 |
$temp[$val[$key]] = $key;
|
983 |
} else {
|
984 |
$temp[$val[$key]] .= " " . $key;
|
@@ -1021,10 +1017,10 @@ class Zend_Locale_Data
|
|
1021 |
$temp = array();
|
1022 |
foreach ($_temp as $key => $keyvalue) {
|
1023 |
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
|
1024 |
-
if (!isset($val[$key])
|
1025 |
continue;
|
1026 |
}
|
1027 |
-
if (!
|
1028 |
$temp[$val[$key]] = $key;
|
1029 |
} else {
|
1030 |
$temp[$val[$key]] .= " " . $key;
|
@@ -1049,7 +1045,7 @@ class Zend_Locale_Data
|
|
1049 |
if ($found3 !== $value) {
|
1050 |
continue;
|
1051 |
}
|
1052 |
-
if (!
|
1053 |
$temp[$found3] = (string) $key;
|
1054 |
} else {
|
1055 |
$temp[$found3] .= " " . $key;
|
@@ -1075,7 +1071,7 @@ class Zend_Locale_Data
|
|
1075 |
if ($found3 !== $value) {
|
1076 |
continue;
|
1077 |
}
|
1078 |
-
if (!
|
1079 |
$temp[$found3] = (string) $key;
|
1080 |
} else {
|
1081 |
$temp[$found3] .= " " . $key;
|
@@ -1101,7 +1097,7 @@ class Zend_Locale_Data
|
|
1101 |
if ($found3 !== $value) {
|
1102 |
continue;
|
1103 |
}
|
1104 |
-
if (!
|
1105 |
$temp[$found3] = (string) $key;
|
1106 |
} else {
|
1107 |
$temp[$found3] .= " " . $key;
|
@@ -1160,14 +1156,57 @@ class Zend_Locale_Data
|
|
1160 |
return $temp;
|
1161 |
}
|
1162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1163 |
|
1164 |
/**
|
1165 |
* Set a cache for Zend_Locale_Data
|
1166 |
*
|
1167 |
-
* @param Zend_Cache_Core $cache
|
1168 |
*/
|
1169 |
public static function setCache(Zend_Cache_Core $cache)
|
1170 |
{
|
1171 |
self::$_cache = $cache;
|
1172 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1173 |
}
|
16 |
* @package Zend_Locale
|
17 |
* @subpackage Data
|
18 |
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
|
|
19 |
* @license http://framework.zend.com/license/new-bsd New BSD License
|
20 |
+
* @version $Id: Data.php 12057 2008-10-21 17:19:43Z thomas $
|
21 |
*/
|
22 |
|
|
|
23 |
/**
|
24 |
* include needed classes
|
25 |
*/
|
26 |
#require_once 'Zend/Locale.php';
|
27 |
|
|
|
28 |
/**
|
29 |
+
* Locale data reader, handles the CLDR
|
30 |
+
*
|
31 |
* @category Zend
|
32 |
* @package Zend_Locale
|
33 |
* @subpackage Data
|
37 |
class Zend_Locale_Data
|
38 |
{
|
39 |
/**
|
40 |
+
* Locale files
|
41 |
*
|
42 |
* @var ressource
|
43 |
* @access private
|
44 |
*/
|
45 |
private static $_ldml = array();
|
46 |
|
|
|
47 |
/**
|
48 |
+
* List of values which are collected
|
49 |
*
|
50 |
* @var array
|
51 |
* @access private
|
52 |
*/
|
53 |
private static $_list = array();
|
54 |
|
|
|
55 |
/**
|
56 |
+
* Internal cache for ldml values
|
57 |
*
|
58 |
* @var Zend_Cache_Core
|
59 |
* @access private
|
60 |
*/
|
61 |
private static $_cache = null;
|
62 |
|
|
|
63 |
/**
|
64 |
* Read the content from locale
|
65 |
*
|
271 |
$locale = new Zend_Locale();
|
272 |
}
|
273 |
|
274 |
+
if (!(Zend_Locale::isLocale((string) $locale, null, false))) {
|
|
|
|
|
|
|
|
|
275 |
#require_once 'Zend/Locale/Exception.php';
|
276 |
+
throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
|
277 |
}
|
278 |
+
|
279 |
+
return (string) $locale;
|
280 |
}
|
281 |
|
282 |
/**
|
291 |
public static function getList($locale, $path, $value = false)
|
292 |
{
|
293 |
$locale = self::_checkLocale($locale);
|
|
|
294 |
if (isset(self::$_cache)) {
|
295 |
$val = $value;
|
296 |
if (is_array($value)) {
|
297 |
$val = implode('_' , $value);
|
298 |
}
|
299 |
+
|
300 |
$val = urlencode($val);
|
301 |
$id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
|
302 |
if ($result = self::$_cache->load($id)) {
|
318 |
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
|
319 |
if ($value === 1) {
|
320 |
foreach($temp as $key => $value) {
|
321 |
+
if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'QU')) {
|
322 |
unset($temp[$key]);
|
323 |
}
|
324 |
}
|
325 |
} else if ($value === 2) {
|
326 |
foreach($temp as $key => $value) {
|
327 |
+
if (is_numeric($key) or ($key == 'QO') or ($key == 'QU')) {
|
328 |
unset($temp[$key]);
|
329 |
}
|
330 |
}
|
552 |
foreach ($_temp as $key => $keyvalue) {
|
553 |
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
|
554 |
if (!isset($val[$key])) {
|
555 |
+
continue;
|
556 |
+
}
|
557 |
+
if (!isset($temp[$val[$key]])) {
|
558 |
$temp[$val[$key]] = $key;
|
559 |
} else {
|
560 |
$temp[$val[$key]] .= " " . $key;
|
600 |
foreach ($_temp as $key => $keyvalue) {
|
601 |
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
|
602 |
if (!isset($val[$key])) {
|
603 |
+
continue;
|
604 |
+
}
|
605 |
+
if (!isset($temp[$val[$key]])) {
|
606 |
$temp[$val[$key]] = $key;
|
607 |
} else {
|
608 |
$temp[$val[$key]] .= " " . $key;
|
626 |
foreach($_temp as $key => $found) {
|
627 |
$_temp3 = explode(" ", $found);
|
628 |
foreach($_temp3 as $found3) {
|
629 |
+
if (!isset($temp[$found3])) {
|
630 |
$temp[$found3] = (string) $key;
|
631 |
} else {
|
632 |
$temp[$found3] .= " " . $key;
|
657 |
if (empty($found3)) {
|
658 |
continue;
|
659 |
}
|
660 |
+
if (!isset($temp[$found3])) {
|
661 |
$temp[$found3] = (string) $key;
|
662 |
} else {
|
663 |
$temp[$found3] .= " " . $key;
|
688 |
if (empty($found3)) {
|
689 |
continue;
|
690 |
}
|
691 |
+
if (!isset($temp[$found3])) {
|
692 |
$temp[$found3] = (string) $key;
|
693 |
} else {
|
694 |
$temp[$found3] .= " " . $key;
|
971 |
$temp = array();
|
972 |
foreach ($_temp as $key => $keyvalue) {
|
973 |
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
|
974 |
+
if (!isset($val[$key]) or ($val[$key] != $value)) {
|
975 |
continue;
|
976 |
}
|
977 |
+
if (!isset($temp[$val[$key]])) {
|
978 |
$temp[$val[$key]] = $key;
|
979 |
} else {
|
980 |
$temp[$val[$key]] .= " " . $key;
|
1017 |
$temp = array();
|
1018 |
foreach ($_temp as $key => $keyvalue) {
|
1019 |
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
|
1020 |
+
if (!isset($val[$key]) or ($val[$key] != $value)) {
|
1021 |
continue;
|
1022 |
}
|
1023 |
+
if (!isset($temp[$val[$key]])) {
|
1024 |
$temp[$val[$key]] = $key;
|
1025 |
} else {
|
1026 |
$temp[$val[$key]] .= " " . $key;
|
1045 |
if ($found3 !== $value) {
|
1046 |
continue;
|
1047 |
}
|
1048 |
+
if (!isset($temp[$found3])) {
|
1049 |
$temp[$found3] = (string) $key;
|
1050 |
} else {
|
1051 |
$temp[$found3] .= " " . $key;
|
1071 |
if ($found3 !== $value) {
|
1072 |
continue;
|
1073 |
}
|
1074 |
+
if (!isset($temp[$found3])) {
|
1075 |
$temp[$found3] = (string) $key;
|
1076 |
} else {
|
1077 |
$temp[$found3] .= " " . $key;
|
1097 |
if ($found3 !== $value) {
|
1098 |
continue;
|
1099 |
}
|
1100 |
+
if (!isset($temp[$found3])) {
|
1101 |
$temp[$found3] = (string) $key;
|
1102 |
} else {
|
1103 |
$temp[$found3] .= " " . $key;
|
1156 |
return $temp;
|
1157 |
}
|
1158 |
|
1159 |
+
/**
|
1160 |
+
* Returns the set cache
|
1161 |
+
*
|
1162 |
+
* @return Zend_Cache_Core The set cache
|
1163 |
+
*/
|
1164 |
+
public static function getCache()
|
1165 |
+
{
|
1166 |
+
return self::$_cache;
|
1167 |
+
}
|
1168 |
|
1169 |
/**
|
1170 |
* Set a cache for Zend_Locale_Data
|
1171 |
*
|
1172 |
+
* @param Zend_Cache_Core $cache A cache frontend
|
1173 |
*/
|
1174 |
public static function setCache(Zend_Cache_Core $cache)
|
1175 |
{
|
1176 |
self::$_cache = $cache;
|
1177 |
}
|
1178 |
+
|
1179 |
+
/**
|
1180 |
+
* Returns true when a cache is set
|
1181 |
+
*
|
1182 |
+
* @return boolean
|
1183 |
+
*/
|
1184 |
+
public static function hasCache()
|
1185 |
+
{
|
1186 |
+
if (self::$_cache !== null) {
|
1187 |
+
return true;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
return false;
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
/**
|
1194 |
+
* Removes any set cache
|
1195 |
+
*
|
1196 |
+
* @return void
|
1197 |
+
*/
|
1198 |
+
public static function removeCache()
|
1199 |
+
{
|
1200 |
+
self::$_cache = null;
|
1201 |
+
}
|
1202 |
+
|