Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

/mvc/components/l10n

[return to app]
1 <?php
2
/**
3  * Localization
4  *
5  * This is CakePHP's l10n class updated to PHP5 syntax for Vork
6  *
7  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8  * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
9  *
10  * Licensed under The MIT License
11  * Redistributions of files must retain the above copyright notice.
12  *
13  * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
14  * @link          http://cakephp.org CakePHP(tm) Project
15  * @package       cake
16  * @subpackage    cake.cake.libs
17  * @since         CakePHP(tm) v 1.2.0.4116
18  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
19  */
20
21 /**
22  * Localization
23  *
24  * @package       cake
25  * @subpackage    cake.cake.libs
26  */
27
class l10nComponent {
28     
/**
29      * The language for current locale
30      *
31      * @var string
32      * @access public
33      */
34     
public $language 'English (United States)';
35
36     
/**
37      * Locale search paths
38      *
39      * @var array
40      * @access public
41      */
42     
public $languagePath = array('eng');
43
44     
/**
45      * ISO 639-3 for current locale
46      *
47      * @var string
48      * @access public
49      */
50     
public $lang 'eng';
51
52     
/**
53      * Locale
54      *
55      * @var string
56      * @access public
57      */
58     
public $locale 'en_us';
59
60     
/**
61      * Default ISO 639-3 language.
62      *
63      * DEFAULT_LANGUAGE is defined in an application this will be set as a fall back
64      *
65      * @var string
66      * @access public
67      */
68     
public $default null;
69
70     
/**
71      * Encoding used for current locale
72      *
73      * @var string
74      * @access public
75      */
76     
public $charset 'utf-8';
77
78     
/**
79      * Text direction for current locale
80      *
81      * @var string
82      * @access public
83      */
84     
public $direction 'ltr';
85
86     
/**
87      * Set to true if a locale is found
88      *
89      * @var string
90      * @access public
91      */
92     
public $found false;
93
94     
/**
95      * Maps ISO 639-3 to I10n::__l10nCatalog
96      *
97      * @var array
98      * @access private
99      */
100     
protected $_l10nMap = array(/* Afrikaans */ 'afr' => 'af',
101                                 
/* Albanian */ 'alb' => 'sq',
102                                 
/* Arabic */ 'ara' => 'ar',
103                                 
/* Armenian - Armenia */ 'hye' => 'hy',
104                                 
/* Basque */ 'baq' => 'eu',
105                                 
/* Bosnian */ 'bos' => 'bs',
106                                 
/* Bulgarian */ 'bul' => 'bg',
107                                 
/* Byelorussian */ 'bel' => 'be',
108                                 
/* Catalan */ 'cat' => 'ca',
109                                 
/* Chinese */ 'chi' => 'zh',
110                                 
/* Chinese */ 'zho' => 'zh',
111                                 
/* Croatian */ 'hrv' => 'hr',
112                                 
/* Czech */ 'cze' => 'cs',
113                                 
/* Czech */ 'ces' => 'cs',
114                                 
/* Danish */ 'dan' => 'da',
115                                 
/* Dutch (Standard) */ 'dut' => 'nl',
116                                 
/* Dutch (Standard) */ 'nld' => 'nl',
117                                 
/* English */ 'eng' => 'en',
118                                 
/* Estonian */ 'est' => 'et',
119                                 
/* Faeroese */ 'fao' => 'fo',
120                                 
/* Farsi */ 'fas' => 'fa',
121                                 
/* Farsi */ 'per' => 'fa',
122                                 
/* Finnish */ 'fin' => 'fi',
123                                 
/* French (Standard) */ 'fre' => 'fr',
124                                 
/* French (Standard) */ 'fra' => 'fr',
125                                 
/* Gaelic (Scots) */ 'gla' => 'gd',
126                                 
/* Galician */ 'glg' => 'gl',
127                                 
/* German (Standard) */ 'deu' => 'de',
128                                 
/* German (Standard) */ 'ger' => 'de',
129                                 
/* Greek */ 'gre' => 'el',
130                                 
/* Greek */ 'ell' => 'el',
131                                 
/* Hebrew */ 'heb' => 'he',
132                                 
/* Hindi */ 'hin' => 'hi',
133                                 
/* Hungarian */ 'hun' => 'hu',
134                                 
/* Icelandic */ 'ice' => 'is',
135                                 
/* Icelandic */ 'isl' => 'is',
136                                 
/* Indonesian */ 'ind' => 'id',
137                                 
/* Irish */ 'gle' => 'ga',
138                                 
/* Italian */ 'ita' => 'it',
139                                 
/* Japanese */ 'jpn' => 'ja',
140                                 
/* Korean */ 'kor' => 'ko',
141                                 
/* Latvian */ 'lav' => 'lv',
142                                 
/* Lithuanian */ 'lit' => 'lt',
143                                 
/* Macedonian */ 'mac' => 'mk',
144                                 
/* Macedonian */ 'mkd' => 'mk',
145                                 
/* Malaysian */ 'may' => 'ms',
146                                 
/* Malaysian */ 'msa' => 'ms',
147                                 
/* Maltese */ 'mlt' => 'mt',
148                                 
/* Norwegian */ 'nor' => 'no',
149                                 
/* Norwegian Bokmal */ 'nob' => 'nb',
150                                 
/* Norwegian Nynorsk */ 'nno' => 'nn',
151                                 
/* Polish */ 'pol' => 'pl',
152                                 
/* Portuguese (Portugal) */ 'por' => 'pt',
153                                 
/* Rhaeto-Romanic */ 'roh' => 'rm',
154                                 
/* Romanian */ 'rum' => 'ro',
155                                 
/* Romanian */ 'ron' => 'ro',
156                                 
/* Russian */ 'rus' => 'ru',
157                                 
/* Sami (Lappish) */ 'smi' => 'sz',
158                                 
/* Serbian */ 'scc' => 'sr',
159                                 
/* Serbian */ 'srp' => 'sr',
160                                 
/* Slovak */ 'slo' => 'sk',
161                                 
/* Slovak */ 'slk' => 'sk',
162                                 
/* Slovenian */ 'slv' => 'sl',
163                                 
/* Sorbian */ 'wen' => 'sb',
164                                 
/* Spanish (Spain - Traditional) */ 'spa' => 'es',
165                                 
/* Swedish */ 'swe' => 'sv',
166                                 
/* Thai */ 'tha' => 'th',
167                                 
/* Tsonga */ 'tso' => 'ts',
168                                 
/* Tswana */ 'tsn' => 'tn',
169                                 
/* Turkish */ 'tur' => 'tr',
170                                 
/* Ukrainian */ 'ukr' => 'uk',
171                                 
/* Urdu */ 'urd' => 'ur',
172                                 
/* Venda */ 'ven' => 've',
173                                 
/* Vietnamese */ 'vie' => 'vi',
174                                 
/* Welsh */ 'cym' => 'cy',
175                                 
/* Xhosa */ 'xho' => 'xh',
176                                 
/* Yiddish */ 'yid' => 'yi',
177                                 
/* Zulu */ 'zul' => 'zu');
178
179     
/**
180      * HTTP_ACCEPT_LANGUAGE catalog
181      *
182      * holds all information related to a language
183      *
184      * @var array
185      * @access private
186      */
187     
protected $_l10nCatalog = array(
188         
'ar-dz' => array('language'            => 'Arabic (Algeria)',
189                          
'locale'            => 'ar_dz',
190                          
'localeFallback'    => 'ara',
191                          
'charset'            => 'utf-8',
192                          
'direction'        => 'rtl'),
193         
'ar-eg' => array('language'            => 'Arabic (Egypt)',
194                          
'locale'            => 'ar_eg',
195                          
'localeFallback'    => 'ara',
196                          
'charset'            => 'utf-8',
197                          
'direction'        => 'rtl'),
198         
'ar-iq' => array('language'            => 'Arabic (Iraq)',
199                          
'locale'            => 'ar_iq',
200                          
'localeFallback'    => 'ara',
201                          
'charset'            => 'utf-8',
202                          
'direction'        => 'rtl'),
203         
'ar-jo' => array('language'            => 'Arabic (Jordan)',
204                          
'locale'            => 'ar_jo',
205                          
'localeFallback'    => 'ara',
206                          
'charset'            => 'utf-8',
207                          
'direction'        => 'rtl'),
208         
'ar-kw' => array('language'            => 'Arabic (Kuwait)',
209                          
'locale'            => 'ar_kw',
210                          
'localeFallback'    => 'ara',
211                          
'charset'            => 'utf-8',
212                          
'direction'        => 'rtl'),
213         
'ar-lb' => array('language'            => 'Arabic (Lebanon)',
214                          
'locale'            => 'ar_lb',
215                          
'localeFallback'    => 'ara',
216                          
'charset'            => 'utf-8',
217                          
'direction'        => 'rtl'),
218         
'ar-ly' => array('language'            => 'Arabic (Libya)',
219                          
'locale'            => 'ar_ly',
220                          
'localeFallback'    => 'ara',
221                          
'charset'            => 'utf-8',
222                          
'direction'        => 'rtl'),
223         
'ar-ma' => array('language'            => 'Arabic (Morocco)',
224                          
'locale'            => 'ar_ma',
225                          
'localeFallback'    => 'ara',
226                          
'charset'            => 'utf-8',
227                          
'direction'        => 'rtl'),
228         
'ar-om' => array('language'            => 'Arabic (Oman)',
229                          
'locale'            => 'ar_om',
230                          
'localeFallback'    => 'ara',
231                          
'charset'            => 'utf-8',
232                          
'direction'        => 'rtl'),
233         
'ar-qa' => array('language'            => 'Arabic (Qatar)',
234                          
'locale'            => 'ar_qa',
235                          
'localeFallback'    => 'ara',
236                          
'charset'            => 'utf-8',
237                          
'direction'        => 'rtl'),
238         
'ar-sa' => array('language'            => 'Arabic (Saudi Arabia)',
239                          
'locale'            => 'ar_sa',
240                          
'localeFallback'    => 'ara',
241                          
'charset'            => 'utf-8',
242                          
'direction'        => 'rtl'),
243         
'ar-sy' => array('language'            => 'Arabic (Syria)',
244                          
'locale'            => 'ar_sy',
245                          
'localeFallback'    => 'ara',
246                          
'charset'            => 'utf-8',
247                          
'direction'        => 'rtl'),
248         
'ar-tn' => array('language'            => 'Arabic (Tunisia)',
249                          
'locale'            => 'ar_tn',
250                          
'localeFallback'    => 'ara',
251                          
'charset'            => 'utf-8',
252                          
'direction'        => 'rtl'),
253         
'ar-ye' => array('language'            => 'Arabic (Yemen)',
254                          
'locale'            => 'ar_ye',
255                          
'localeFallback'    => 'ara',
256                          
'charset'            => 'utf-8',
257                          
'direction'        => 'rtl'),
258         
'be' => array('language'            => 'Byelorussian',
259                          
'locale'            => 'bel',
260                          
'localeFallback'    => 'bel',
261                          
'charset'            => 'utf-8',
262                          
'direction'        => 'ltr'),
263         
'bg' => array('language'            => 'Bulgarian',
264                          
'locale'            => 'bul',
265                          
'localeFallback'    => 'bul',
266                          
'charset'            => 'utf-8',
267                          
'direction'        => 'ltr'),
268         
'bs' => array('language'            => 'Bosnian',
269                          
'locale'            => 'bos',
270                          
'localeFallback'    => 'bos',
271                          
'charset'            => 'utf-8',
272                          
'direction'        => 'ltr'),
273         
'ca' => array('language'            => 'Catalan',
274                          
'locale'            => 'cat',
275                          
'localeFallback'    => 'cat',
276                          
'charset'            => 'utf-8',
277                          
'direction'        => 'ltr'),
278         
'cs' => array('language'            => 'Czech',
279                          
'locale'            => 'cze',
280                          
'localeFallback'    => 'cze',
281                          
'charset'            => 'utf-8',
282                          
'direction'        => 'ltr'),
283         
'da' => array('language'            => 'Danish',
284                          
'locale'            => 'dan',
285                          
'localeFallback'    => 'dan',
286                          
'charset'            => 'utf-8',
287                          
'direction'        => 'ltr'),
288         
'de' => array('language'            => 'German (Standard)',
289                          
'locale'            => 'deu',
290                          
'localeFallback'    => 'deu',
291                          
'charset'            => 'utf-8',
292                          
'direction'        => 'ltr'),
293         
'de-at' => array('language'            => 'German (Austria)',
294                          
'locale'            => 'de_at',
295                          
'localeFallback'    => 'deu',
296                          
'charset'            => 'utf-8',
297                          
'direction'        => 'ltr'),
298         
'de-ch' => array('language'            => 'German (Swiss)',
299                          
'locale'            => 'de_ch',
300                          
'localeFallback'    => 'deu',
301                          
'charset'            => 'utf-8',
302                          
'direction'        => 'ltr'),
303         
'de-de' => array('language'            => 'German (Germany)',
304                          
'locale'            => 'de_de',
305                          
'localeFallback'    => 'deu',
306                          
'charset'            => 'utf-8',
307                          
'direction'        => 'ltr'),
308         
'de-li' => array('language'            => 'German (Liechtenstein)',
309                          
'locale'            => 'de_li',
310                          
'localeFallback'    => 'deu',
311                          
'charset'            => 'utf-8',
312                          
'direction'        => 'ltr'),
313         
'de-lu' => array('language'            => 'German (Luxembourg)',
314                          
'locale'            => 'de_lu',
315                          
'localeFallback'    => 'deu',
316                          
'charset'            => 'utf-8',
317                          
'direction'        => 'ltr'),
318         
'e' => array('language'                => 'Greek',
319                          
'locale'            => 'gre',
320                          
'localeFallback'    => 'gre',
321                          
'charset'            => 'utf-8',
322                          
'direction'        => 'ltr'),
323         
'el' => array('language'            => 'Greek',
324                          
'locale'            => 'gre',
325                          
'localeFallback'    => 'gre',
326                          
'charset'            => 'utf-8',
327                          
'direction'        => 'ltr'),
328         
'en' => array('language'            => 'English',
329                          
'locale'            => 'eng',
330                          
'localeFallback'    => 'eng',
331                          
'charset'            => 'utf-8',
332                          
'direction'        => 'ltr'),
333         
'en-au' => array('language'            => 'English (Australian)',
334                          
'locale'            => 'en_au',
335                          
'localeFallback'    => 'eng',
336                          
'charset'            => 'utf-8',
337                          
'direction'        => 'ltr'),
338         
'en-bz' => array('language'            => 'English (Belize)',
339                          
'locale'            => 'en_bz',
340                          
'localeFallback'    => 'eng',
341                          
'charset'            => 'utf-8',
342                          
'direction'        => 'ltr'),
343         
'en-ca' => array('language'            => 'English (Canadian)',
344                          
'locale'            => 'en_ca',
345                          
'localeFallback'    => 'eng',
346                          
'charset'            => 'utf-8',
347                          
'direction'        => 'ltr'),
348         
'en-gb' => array('language'            => 'English (British)',
349                          
'locale'            => 'en_gb',
350                          
'localeFallback'    => 'eng',
351                          
'charset'            => 'utf-8',
352                          
'direction'        => 'ltr'),
353         
'en-ie' => array('language'            => 'English (Ireland)',
354                          
'locale'            => 'en_ie',
355                          
'localeFallback'    => 'eng',
356                          
'charset'            => 'utf-8',
357                          
'direction'        => 'ltr'),
358         
'en-jm' => array('language'            => 'English (Jamaica)',
359                          
'locale'            => 'en_jm',
360                          
'localeFallback'    => 'eng',
361                          
'charset'            => 'utf-8',
362                          
'direction'        => 'ltr'),
363         
'en-nz' => array('language'            => 'English (New Zealand)',
364                          
'locale'            => 'en_nz',
365                          
'localeFallback'    => 'eng',
366                          
'charset'            => 'utf-8',
367                          
'direction'        => 'ltr'),
368         
'en-tt' => array('language'            => 'English (Trinidad)',
369                          
'locale'            => 'en_tt',
370                          
'localeFallback'    => 'eng',
371                          
'charset'            => 'utf-8',
372                          
'direction'        => 'ltr'),
373         
'en-us' => array('language'            => 'English (United States)',
374                          
'locale'            => 'en_us',
375                          
'localeFallback'    => 'eng',
376                          
'charset'            => 'utf-8',
377                          
'direction'        => 'ltr'),
378         
'en-za' => array('language'            => 'English (South Africa)',
379                          
'locale'            => 'en_za',
380                          
'localeFallback'    => 'eng',
381                          
'charset'            => 'utf-8',
382                          
'direction'        => 'ltr'),
383         
'es' => array('language'            => 'Spanish (Spain - Traditional)',
384                          
'locale'            => 'spa',
385                          
'localeFallback'    => 'spa',
386                          
'charset'            => 'utf-8',
387                          
'direction'        => 'ltr'),
388         
'es-ar' => array('language'            => 'Spanish (Argentina)',
389                          
'locale'            => 'es_ar',
390                          
'localeFallback'    => 'spa',
391                          
'charset'            => 'utf-8',
392                          
'direction'        => 'ltr'),
393         
'es-bo' => array('language'            => 'Spanish (Bolivia)',
394                          
'locale'            => 'es_bo',
395                          
'localeFallback'    => 'spa',
396                          
'charset'            => 'utf-8',
397                          
'direction'        => 'ltr'),
398         
'es-cl' => array('language'            => 'Spanish (Chile)',
399                          
'locale'            => 'es_cl',
400                          
'localeFallback'    => 'spa',
401                          
'charset'            => 'utf-8',
402                          
'direction'        => 'ltr'),
403         
'es-co' => array('language'            => 'Spanish (Colombia)',
404                          
'locale'            => 'es_co',
405                          
'localeFallback'    => 'spa',
406                          
'charset'            => 'utf-8',
407                          
'direction'        => 'ltr'),
408         
'es-cr' => array('language'            => 'Spanish (Costa Rica)',
409                          
'locale'            => 'es_cr',
410                          
'localeFallback'    => 'spa',
411                          
'charset'            => 'utf-8',
412                          
'direction'        => 'ltr'),
413         
'es-do' => array('language'            => 'Spanish (Dominican Republic)',
414                          
'locale'            => 'es_do',
415                          
'localeFallback'    => 'spa',
416                          
'charset'            => 'utf-8',
417                          
'direction'        => 'ltr'),
418         
'es-ec' => array('language'            => 'Spanish (Ecuador)',
419                          
'locale'            => 'es_ec',
420                          
'localeFallback'    => 'spa',
421                          
'charset'            => 'utf-8',
422                          
'direction'        => 'ltr'),
423         
'es-es' => array('language'            => 'Spanish (Spain)',
424                          
'locale'            => 'es_es',
425                          
'localeFallback'    => 'spa',
426                          
'charset'            => 'utf-8',
427                          
'direction'        => 'ltr'),
428         
'es-gt' => array('language'            => 'Spanish (Guatemala)',
429                          
'locale'            => 'es_gt',
430                          
'localeFallback'    => 'spa',
431                          
'charset'            => 'utf-8',
432                          
'direction'        => 'ltr'),
433         
'es-hn' => array('language'            => 'Spanish (Honduras)',
434                          
'locale'            => 'es_hn',
435                          
'localeFallback'    => 'spa',
436                          
'charset'            => 'utf-8',
437                          
'direction'        => 'ltr'),
438         
'es-mx' => array('language'            => 'Spanish (Mexican)',
439                          
'locale'            => 'es_mx',
440                          
'localeFallback'    => 'spa',
441                          
'charset'            => 'utf-8',
442                          
'direction'        => 'ltr'),
443         
'es-ni' => array('language'            => 'Spanish (Nicaragua)',
444                          
'locale'            => 'es_ni',
445                          
'localeFallback'    => 'spa',
446                          
'charset'            => 'utf-8',
447                          
'direction'        => 'ltr'),
448         
'es-pa' => array('language'            => 'Spanish (Panama)',
449                          
'locale'            => 'es_pa',
450                          
'localeFallback'    => 'spa',
451                          
'charset'            => 'utf-8',
452                          
'direction'        => 'ltr'),
453         
'es-pe' => array('language'            => 'Spanish (Peru)',
454                          
'locale'            => 'es_pe',
455                          
'localeFallback'    => 'spa',
456                          
'charset'            => 'utf-8',
457                          
'direction'        => 'ltr'),
458         
'es-pr' => array('language'            => 'Spanish (Puerto Rico)',
459                          
'locale'            => 'es_pr',
460                          
'localeFallback'    => 'spa',
461                          
'charset'            => 'utf-8',
462                          
'direction'        => 'ltr'),
463         
'es-py' => array('language'            => 'Spanish (Paraguay)',
464                          
'locale'            => 'es_py',
465                          
'localeFallback'    => 'spa',
466                          
'charset'            => 'utf-8',
467                          
'direction'        => 'ltr'),
468         
'es-sv' => array('language'            => 'Spanish (El Salvador)',
469                          
'locale'            => 'es_sv',
470                          
'localeFallback'    => 'spa',
471                          
'charset'            => 'utf-8',
472                          
'direction'        => 'ltr'),
473         
'es-uy' => array('language'            => 'Spanish (Uruguay)',
474                          
'locale'            => 'es_uy',
475                          
'localeFallback'    => 'spa',
476                          
'charset'            => 'utf-8',
477                          
'direction'        => 'ltr'),
478         
'es-ve' => array('language'            => 'Spanish (Venezuela)',
479                          
'locale'            => 'es_ve',
480                          
'localeFallback'    => 'spa',
481                          
'charset'            => 'utf-8',
482                          
'direction'        => 'ltr'),
483         
'et' => array('language'            => 'Estonian',
484                          
'locale'            => 'est',
485                          
'localeFallback'    => 'est',
486                          
'charset'            => 'utf-8',
487                          
'direction'        => 'ltr'),
488         
'eu' => array('language'            => 'Basque',
489                          
'locale'            => 'baq',
490                          
'localeFallback'    => 'baq',
491                          
'charset'            => 'utf-8',
492                          
'direction'        => 'ltr'),
493         
'fa' => array('language'            => 'Farsi',
494                          
'locale'            => 'per',
495                          
'localeFallback'    => 'per',
496                          
'charset'            => 'utf-8',
497                          
'direction'        => 'rtl'),
498         
'fi' => array('language'            => 'Finnish',
499                          
'locale'            => 'fin',
500                          
'localeFallback'    => 'fin',
501                          
'charset'            => 'utf-8',
502                          
'direction'        => 'ltr'),
503         
'fo' => array('language'            => 'Faeroese',
504                          
'locale'            => 'fao',
505                          
'localeFallback'    => 'fao',
506                          
'charset'            => 'utf-8',
507                          
'direction'        => 'ltr'),
508         
'fr' => array('language'            => 'French (Standard)',
509                          
'locale'            => 'fre',
510                          
'localeFallback'    => 'fre',
511                          
'charset'            => 'utf-8',
512                          
'direction'        => 'ltr'),
513         
'fr-be' => array('language'            => 'French (Belgium)',
514                          
'locale'            => 'fr_be',
515                          
'localeFallback'    => 'fre',
516                          
'charset'            => 'utf-8',
517                          
'direction'        => 'ltr'),
518         
'fr-ca' => array('language'            => 'French (Canadian)',
519                          
'locale'            => 'fr_ca',
520                          
'localeFallback'    => 'fre',
521                          
'charset'            => 'utf-8',
522                          
'direction'        => 'ltr'),
523         
'fr-ch' => array('language'            => 'French (Swiss)',
524                          
'locale'            => 'fr_ch',
525                          
'localeFallback'    => 'fre',
526                          
'charset'            => 'utf-8',
527                          
'direction'        => 'ltr'),
528         
'fr-fr' => array('language'            => 'French (France)',
529                          
'locale'            => 'fr_fr',
530                          
'localeFallback'    => 'fre',
531                          
'charset'            => 'utf-8',
532                          
'direction'        => 'ltr'),
533         
'fr-lu' => array('language'            => 'French (Luxembourg)',
534                          
'locale'            => 'fr_lu',
535                          
'localeFallback'    => 'fre',
536                          
'charset'            => 'utf-8',
537                          
'direction'        => 'ltr'),
538         
'ga' => array('language'            => 'Irish',
539                          
'locale'            => 'gle',
540                          
'localeFallback'    => 'gle',
541                          
'charset'            => 'utf-8',
542                          
'direction'        => 'ltr'),
543         
'gd' => array('language'            => 'Gaelic (Scots)',
544                          
'locale'            => 'gla',
545                          
'localeFallback'    => 'gla',
546                          
'charset'            => 'utf-8',
547                          
'direction'        => 'ltr'),
548         
'gd-ie' => array('language'            => 'Gaelic (Irish)',
549                          
'locale'            => 'gd_ie',
550                          
'localeFallback'    => 'gla',
551                          
'charset'            => 'utf-8',
552                          
'direction'        => 'ltr'),
553         
'gl' => array('language'            => 'Galician',
554                          
'locale'            => 'glg',
555                          
'localeFallback'    => 'glg',
556                          
'charset'            => 'utf-8',
557                          
'direction'        => 'ltr'),
558         
'he' => array('language'            => 'Hebrew',
559                          
'locale'            => 'heb',
560                          
'localeFallback'    => 'heb',
561                          
'charset'            => 'utf-8',
562                          
'direction'        => 'rtl'),
563         
'hi' => array('language'            => 'Hindi',
564                          
'locale'            => 'hin',
565                          
'localeFallback'    => 'hin',
566                          
'charset'            => 'utf-8',
567                          
'direction'        => 'ltr'),
568         
'hr' => array('language'            => 'Croatian',
569                          
'locale'            => 'hrv',
570                          
'localeFallback'    => 'hrv',
571                          
'charset'            => 'utf-8',
572                          
'direction'        => 'ltr'),
573         
'hu' => array('language'            => 'Hungarian',
574                          
'locale'            => 'hun',
575                          
'localeFallback'    => 'hun',
576                          
'charset'            => 'utf-8',
577                          
'direction'        => 'ltr'),
578         
'hy' => array('language'            => 'Armenian - Armenia',
579                          
'locale'            => 'hye',
580                          
'localeFallback'    => 'hye',
581                          
'charset'            => 'utf-8',
582                          
'direction'        => 'ltr'),
583         
'id' => array('language'            => 'Indonesian',
584                          
'locale'            => 'ind',
585                          
'localeFallback'    => 'ind',
586                          
'charset'            => 'utf-8',
587                          
'direction'        => 'ltr'),
588         
'in' => array('language'            => 'Indonesian',
589                          
'locale'            => 'ind',
590                          
'localeFallback'    => 'ind',
591                          
'charset'            => 'utf-8',
592                          
'direction'        => 'ltr'),
593         
'is' => array('language'            => 'Icelandic',
594                          
'locale'            => 'ice',
595                          
'localeFallback'    => 'ice',
596                          
'charset'            => 'utf-8',
597                          
'direction'        => 'ltr'),
598         
'it' => array('language'            => 'Italian',
599                          
'locale'            => 'ita',
600                          
'localeFallback'    => 'ita',
601                          
'charset'            => 'utf-8',
602                          
'direction'        => 'ltr'),
603         
'it-ch' => array('language'            => 'Italian (Swiss) ',
604                          
'locale'            => 'it_ch',
605                          
'localeFallback'    => 'ita',
606                          
'charset'            => 'utf-8',
607                          
'direction'        => 'ltr'),
608         
'ja' => array('language'            => 'Japanese',
609                          
'locale'            => 'jpn',
610                          
'localeFallback'    => 'jpn',
611                          
'charset'            => 'utf-8',
612                          
'direction'        => 'ltr'),
613         
'ko' => array('language'            => 'Korean',
614                          
'locale'            => 'kor',
615                          
'localeFallback'    => 'kor',
616                          
'charset'            => 'kr',
617                          
'direction'        => 'ltr'),
618         
'ko-kp' => array('language'            => 'Korea (North)',
619                          
'locale'            => 'ko_kp',
620                          
'localeFallback'    => 'kor',
621                          
'charset'            => 'kr',
622                          
'direction'        => 'ltr'),
623         
'ko-kr' => array('language'            => 'Korea (South)',
624                          
'locale'            => 'ko_kr',
625                          
'localeFallback'    => 'kor',
626                          
'charset'            => 'kr',
627                          
'direction'        => 'ltr'),
628         
'koi8-r' => array('language'        => 'Russian',
629                          
'locale'            => 'koi8_r',
630                          
'localeFallback'    => 'rus',
631                          
'charset'            => 'koi8-r',
632                          
'direction'        => 'ltr'),
633         
'lt' => array('language'            => 'Lithuanian',
634                          
'locale'            => 'lit',
635                          
'localeFallback'    => 'lit',
636                          
'charset'            => 'utf-8',
637                          
'direction'        => 'ltr'),
638         
'lv' => array('language'            => 'Latvian',
639                          
'locale'            => 'lav',
640                          
'localeFallback'    => 'lav',
641                          
'charset'            => 'utf-8',
642                          
'direction'        => 'ltr'),
643         
'mk' => array('language'            => 'FYRO Macedonian',
644                          
'locale'            => 'mk',
645                          
'localeFallback'    => 'mac',
646                          
'charset'            => 'utf-8',
647                          
'direction'        => 'ltr'),
648         
'mk-mk' => array('language'            => 'Macedonian',
649                          
'locale'            => 'mk_mk',
650                          
'localeFallback'    => 'mac',
651                          
'charset'            => 'utf-8',
652                          
'direction'        => 'ltr'),
653         
'ms' => array('language'            => 'Malaysian',
654                          
'locale'            => 'may',
655                          
'localeFallback'    => 'may',
656                          
'charset'            => 'utf-8',
657                          
'direction'        => 'ltr'),
658         
'mt' => array('language'            => 'Maltese',
659                          
'locale'            => 'mlt',
660                          
'localeFallback'    => 'mlt',
661                          
'charset'            => 'utf-8',
662                          
'direction'        => 'ltr'),
663         
'n' => array('language'                => 'Dutch (Standard)',
664                          
'locale'            => 'dut',
665                          
'localeFallback'    => 'dut',
666                          
'charset'            => 'utf-8',
667                          
'direction'        => 'ltr'),
668         
'nb' => array('language'            => 'Norwegian Bokmal',
669                          
'locale'            => 'nob',
670                          
'localeFallback'    => 'nor',
671                          
'charset'            => 'utf-8',
672                          
'direction'        => 'ltr'),
673         
'nl' => array('language'            => 'Dutch (Standard)',
674                          
'locale'            => 'dut',
675                          
'localeFallback'    => 'dut',
676                          
'charset'            => 'utf-8',
677                          
'direction'        => 'ltr'),
678         
'nl-be' => array('language'            => 'Dutch (Belgium)',
679                          
'locale'            => 'nl_be',
680                          
'localeFallback'    => 'dut',
681                          
'charset'            => 'utf-8',
682                          
'direction'        => 'ltr'),
683         
'nn' => array('language'            => 'Norwegian Nynorsk',
684                          
'locale'            => 'nno',
685                          
'localeFallback'    => 'nor',
686                          
'charset'            => 'utf-8',
687                          
'direction'        => 'ltr'),
688         
'no' => array('language'            => 'Norwegian',
689                          
'locale'            => 'nor',
690                          
'localeFallback'    => 'nor',
691                          
'charset'            => 'utf-8',
692                          
'direction'        => 'ltr'),
693         
'p' => array('language'                => 'Polish',
694                          
'locale'            => 'pol',
695                          
'localeFallback'    => 'pol',
696                          
'charset'            => 'utf-8',
697                          
'direction'        => 'ltr'),
698         
'pl' => array('language'            => 'Polish',
699                          
'locale'            => 'pol',
700                          
'localeFallback'    => 'pol',
701                          
'charset'            => 'utf-8',
702                          
'direction'        => 'ltr'),
703         
'pt' => array('language'            => 'Portuguese (Portugal)',
704                          
'locale'            => 'por',
705                          
'localeFallback'    => 'por',
706                          
'charset'            => 'utf-8',
707                          
'direction'        => 'ltr'),
708         
'pt-br' => array('language'            => 'Portuguese (Brazil)',
709                          
'locale'            => 'pt_br',
710                          
'localeFallback'    => 'por',
711                          
'charset'            => 'utf-8',
712                          
'direction'        => 'ltr'),
713         
'rm' => array('language'            => 'Rhaeto-Romanic',
714                          
'locale'            => 'roh',
715                          
'localeFallback'    => 'roh',
716                          
'charset'            => 'utf-8',
717                          
'direction'        => 'ltr'),
718         
'ro' => array('language'            => 'Romanian',
719                          
'locale'            => 'rum',
720                          
'localeFallback'    => 'rum',
721                          
'charset'            => 'utf-8',
722                          
'direction'        => 'ltr'),
723         
'ro-mo' => array('language'            => 'Romanian (Moldavia)',
724                          
'locale'            => 'ro_mo',
725                          
'localeFallback'    => 'rum',
726                          
'charset'            => 'utf-8',
727                          
'direction'        => 'ltr'),
728         
'ru' => array('language'            => 'Russian',
729                          
'locale'            => 'rus',
730                          
'localeFallback'    => 'rus',
731                          
'charset'            => 'utf-8',
732                          
'direction'        => 'ltr'),
733         
'ru-mo' => array('language'            => 'Russian (Moldavia)',
734                          
'locale'            => 'ru_mo',
735                          
'localeFallback'    => 'rus',
736                          
'charset'            => 'utf-8',
737                          
'direction'        => 'ltr'),
738         
'sb' => array('language'            => 'Sorbian',
739                          
'locale'            => 'wen',
740                          
'localeFallback'    => 'wen',
741                          
'charset'            => 'utf-8',
742                          
'direction'        => 'ltr'),
743         
'sk' => array('language'            => 'Slovak',
744                          
'locale'            => 'slo',
745                          
'localeFallback'    => 'slo',
746                          
'charset'            => 'utf-8',
747                          
'direction'        => 'ltr'),
748         
'sl' => array('language'            => 'Slovenian',
749                          
'locale'            => 'slv',
750                          
'localeFallback'    => 'slv',
751                          
'charset'            => 'utf-8',
752                          
'direction'        => 'ltr'),
753         
'sq' => array('language'            => 'Albanian',
754                          
'locale'            => 'alb',
755                          
'localeFallback'    => 'alb',
756                          
'charset'            => 'utf-8',
757                          
'direction'        => 'ltr'),
758         
'sr' => array('language'            => 'Serbian',
759                          
'locale'            => 'scc',
760                          
'localeFallback'    => 'scc',
761                          
'charset'            => 'utf-8',
762                          
'direction'        => 'ltr'),
763         
'sv' => array('language'            => 'Swedish',
764                          
'locale'            => 'swe',
765                          
'localeFallback'    => 'swe',
766                          
'charset'            => 'utf-8',
767                          
'direction'        => 'ltr'),
768         
'sv-fi' => array('language'            => 'Swedish (Finland)',
769                          
'locale'            => 'sv_fi',
770                          
'localeFallback'    => 'swe',
771                          
'charset'            => 'utf-8',
772                          
'direction'        => 'ltr'),
773         
'sx' => array('language'            => 'Sutu',
774                          
'locale'            => 'sx',
775                          
'localeFallback'    => 'sx',
776                          
'charset'            => 'utf-8',
777                          
'direction'        => 'ltr'),
778         
'sz' => array('language'            => 'Sami (Lappish)',
779                          
'locale'            => 'smi',
780                          
'localeFallback'    => 'smi',
781                          
'charset'            => 'utf-8',
782                          
'direction'        => 'ltr'),
783         
'th' => array('language'            => 'Thai',
784                          
'locale'            => 'tha',
785                          
'localeFallback'    => 'tha',
786                          
'charset'            => 'utf-8',
787                          
'direction'        => 'ltr'),
788         
'tn' => array('language'            => 'Tswana',
789                          
'locale'            => 'tsn',
790                          
'localeFallback'    => 'tsn',
791                          
'charset'            => 'utf-8',
792                          
'direction'        => 'ltr'),
793         
'tr' => array('language'            => 'Turkish',
794                          
'locale'            => 'tur',
795                          
'localeFallback'    => 'tur',
796                          
'charset'            => 'utf-8',
797                          
'direction'        => 'ltr'),
798         
'ts' => array('language'            => 'Tsonga',
799                          
'locale'            => 'tso',
800                          
'localeFallback'    => 'tso',
801                          
'charset'            => 'utf-8',
802                          
'direction'        => 'ltr'),
803         
'uk' => array('language'            => 'Ukrainian',
804                          
'locale'            => 'ukr',
805                          
'localeFallback'    => 'ukr',
806                          
'charset'            => 'utf-8',
807                          
'direction'        => 'ltr'),
808         
'ur' => array('language'            => 'Urdu',
809                          
'locale'            => 'urd',
810                          
'localeFallback'    => 'urd',
811                          
'charset'            => 'utf-8',
812                          
'direction'        => 'rtl'),
813         
've' => array('language'            => 'Venda',
814                          
'locale'            => 'ven',
815                          
'localeFallback'    => 'ven',
816                          
'charset'            => 'utf-8',
817                          
'direction'        => 'ltr'),
818         
'vi' => array('language'            => 'Vietnamese',
819                          
'locale'            => 'vie',
820                          
'localeFallback'    => 'vie',
821                          
'charset'            => 'utf-8',
822                          
'direction'        => 'ltr'),
823         
'cy' => array('language'            => 'Welsh',
824                          
'locale'            => 'cym',
825                          
'localeFallback'    => 'cym',
826                          
'charset'            => 'utf-8',
827                          
'direction'        => 'ltr'),
828         
'xh' => array('language'            => 'Xhosa',
829                          
'locale'            => 'xho',
830                          
'localeFallback'    => 'xho',
831                          
'charset'            => 'utf-8',
832                          
'direction'        => 'ltr'),
833         
'yi' => array('language'            => 'Yiddish',
834                          
'locale'            => 'yid',
835                          
'localeFallback'    => 'yid',
836                          
'charset'            => 'utf-8',
837                          
'direction'        => 'ltr'),
838         
'zh' => array('language'            => 'Chinese',
839                          
'locale'            => 'chi',
840                          
'localeFallback'    => 'chi',
841                          
'charset'            => 'utf-8',
842                          
'direction'        => 'ltr'),
843         
'zh-cn' => array('language'            => 'Chinese (PRC)',
844                          
'locale'            => 'zh_cn',
845                          
'localeFallback'    => 'chi',
846                          
'charset'            => 'GB2312',
847                          
'direction'        => 'ltr'),
848         
'zh-hk' => array('language'            => 'Chinese (Hong Kong)',
849                          
'locale'            => 'zh_hk',
850                          
'localeFallback'    => 'chi',
851                          
'charset'            => 'utf-8',
852                          
'direction'        => 'ltr'),
853         
'zh-sg' => array('language'            => 'Chinese (Singapore)',
854                          
'locale'            => 'zh_sg',
855                          
'localeFallback'    => 'chi',
856                          
'charset'            => 'utf-8',
857                          
'direction'        => 'ltr'),
858         
'zh-tw' => array('language'            => 'Chinese (Taiwan)',
859                          
'locale'            => 'zh_tw',
860                          
'localeFallback'    => 'chi',
861                          
'charset'            => 'utf-8',
862                          
'direction'        => 'ltr'),
863         
'zu' => array('language'            => 'Zulu',
864                          
'locale'            => 'zul',
865                          
'localeFallback'    => 'zul',
866                          
'charset'            => 'utf-8',
867                          
'direction'        => 'ltr'));
868
869     
/**
870      * Class constructor
871      */
872     
public function __construct() {
873         if (
defined('DEFAULT_LANGUAGE')) {
874             
$this->default DEFAULT_LANGUAGE;
875         }
876     }
877
878     
/**
879      * Gets the settings for $language.
880      * If $language is null it attempt to get settings from L10n::__autoLanguage(); if this fails
881      * the method will get the settings from L10n::__setLanguage();
882      *
883      * @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
884      * @access public
885      */
886     
public function get($language null) {
887         if (
$language !== null) {
888             return 
$this->_setLanguage($language);
889         } elseif (
$this->_autoLanguage() === false) {
890             return 
$this->_setLanguage();
891         }
892     }
893
894     
/**
895      * Sets the class vars to correct values for $language.
896      * If $language is null it will use the DEFAULT_LANGUAGE if defined
897      *
898      * @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
899      * @access private
900      */
901     
protected function _setLanguage($language null) {
902         
$langKey null;
903         if (
$language !== null && isset($this->_l10nMap[$language])
904             && isset(
$this->_l10nCatalog[$this->_l10nMap[$language]])) {
905             
$langKey $this->_l10nMap[$language];
906         } else if (
$language !== null && isset($this->_l10nCatalog[$language])) {
907             
$langKey $language;
908         } else if (
defined('DEFAULT_LANGUAGE')) {
909             
$langKey $language DEFAULT_LANGUAGE;
910         }
911
912         if (
$langKey !== null && isset($this->_l10nCatalog[$langKey])) {
913             
$this->language $this->_l10nCatalog[$langKey]['language'];
914             
$this->languagePath = array(
915                 
$this->_l10nCatalog[$langKey]['locale'],
916                 
$this->_l10nCatalog[$langKey]['localeFallback']
917             );
918             
$this->lang $language;
919             
$this->locale $this->_l10nCatalog[$langKey]['locale'];
920             
$this->charset $this->_l10nCatalog[$langKey]['charset'];
921             
$this->direction $this->_l10nCatalog[$langKey]['direction'];
922         } else {
923             
$this->lang $language;
924             
$this->languagePath = array($language);
925         }
926
927         if (
$this->default) {
928             if (isset(
$this->_l10nMap[$this->default]) &&
 
isset($this->_l10nCatalog[$this->_l10nMap[$this->default]])) {
929                 
$this->languagePath[] = $this->_l10nCatalog[$this->_l10nMap[$this->default]]['localeFallback'];
930             } else if (isset(
$this->_l10nCatalog[$this->default])) {
931                 
$this->languagePath[] = $this->_l10nCatalog[$this->default]['localeFallback'];
932             }
933         }
934         
$this->found true;
935
936         if (
$language) {
937             return 
$language;
938         }
939     }
940
941     
/**
942      * Attempts to find the locale settings based on the HTTP_ACCEPT_LANGUAGE variable
943      *
944      * @return boolean Success
945      * @access private
946      */
947     
protected function _autoLanguage() {
948         
$_detectableLanguages preg_split('/[,;]/'env('HTTP_ACCEPT_LANGUAGE'));
949         foreach (
$_detectableLanguages as $key => $langKey) {
950             
$langKey strtolower($langKey);
951             if (
strpos($langKey'_') !== false) {
952                 
$langKey str_replace('_''-'$langKey);
953             }
954
955             if (isset(
$this->_l10nCatalog[$langKey])) {
956                 
$this->_setLanguage($langKey);
957                 return 
true;
958             } else if (
strpos($langKey'-') !== false) {
959                 
$langKey substr($langKey02);
960                 if (isset(
$this->_l10nCatalog[$langKey])) {
961                     
$this->_setLanguage($langKey);
962                     return 
true;
963                 }
964             }
965         }
966         return 
false;
967     }
968
969     
/**
970      * Attempts to find locale for language, or language for locale
971      *
972      * @param mixed $mixed 2/3 char string (language/locale), array of those strings, or null
973      * @return mixed string language/locale, array of those values, whole map as an array,
974      *    or false when language/locale doesn't exist
975      * @access public
976      */
977     
public function map($mixed null) {
978         if (
is_array($mixed)) {
979             
$result = array();
980             foreach (
$mixed as $_mixed) {
981                 if (
$_result $this->map($_mixed)) {
982                     
$result[$_mixed] = $_result;
983                 }
984             }
985             return 
$result;
986         } else if (
is_string($mixed)) {
987             if (
strlen($mixed) === && in_array($mixed$this->_l10nMap)) {
988                 return 
array_search($mixed$this->_l10nMap);
989             } else if (isset(
$this->_l10nMap[$mixed])) {
990                 return 
$this->_l10nMap[$mixed];
991             }
992             return 
false;
993         }
994         return 
$this->_l10nMap;
995     }
996
997     
/**
998      * Attempts to find catalog record for requested language
999      *
1000      * @param mixed $language string requested language, array of requested languages, or null for whole catalog
1001      * @return mixed array catalog record for requested language, array of catalog records, whole catalog,
1002      *    or false when language doesn't exist
1003      * @access public
1004      */
1005     
public function catalog($language null) {
1006         if (
is_array($language)) {
1007             
$result = array();
1008             foreach (
$language as $_language) {
1009                 if (
$_result $this->catalog($_language)) {
1010                     
$result[$_language] = $_result;
1011                 }
1012             }
1013             return 
$result;
1014         } else if (
is_string($language)) {
1015             if (isset(
$this->_l10nCatalog[$language])) {
1016                 return 
$this->_l10nCatalog[$language];
1017             } else if (isset(
$this->_l10nMap[$language]) &&
 
isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
1018                 return 
$this->_l10nCatalog[$this->_l10nMap[$language]];
1019             }
1020             return 
false;
1021         }
1022         return 
$this->_l10nCatalog;
1023     }
1024 }