Locale.php 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Locale
  17. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * Base class for localization
  23. *
  24. * @category Zend
  25. * @package Zend_Locale
  26. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Locale
  30. {
  31. /**
  32. * List of locales that are no longer part of CLDR along with a
  33. * mapping to an appropriate alternative.
  34. *
  35. * @var array
  36. */
  37. private static $_localeAliases = array(
  38. 'az_AZ' => 'az_Latn_AZ',
  39. 'bs_BA' => 'bs_Latn_BA',
  40. 'ha_GH' => 'ha_Latn_GH',
  41. 'ha_NE' => 'ha_Latn_NE',
  42. 'ha_NG' => 'ha_Latn_NG',
  43. 'kk_KZ' => 'kk_Cyrl_KZ',
  44. 'ks_IN' => 'ks_Arab_IN',
  45. 'mn_MN' => 'mn_Cyrl_MN',
  46. 'ms_BN' => 'ms_Latn_BN',
  47. 'ms_MY' => 'ms_Latn_MY',
  48. 'ms_SG' => 'ms_Latn_SG',
  49. 'pa_IN' => 'pa_Guru_IN',
  50. 'pa_PK' => 'pa_Arab_PK',
  51. 'shi_MA' => 'shi_Latn_MA',
  52. 'sr_BA' => 'sr_Latn_BA',
  53. 'sr_ME' => 'sr_Latn_ME',
  54. 'sr_RS' => 'sr_Latn_RS',
  55. 'sr_XK' => 'sr_Latn_XK',
  56. 'tg_TJ' => 'tg_Cyrl_TJ',
  57. 'tzm_MA' => 'tzm_Latn_MA',
  58. 'uz_AF' => 'uz_Arab_AF',
  59. 'uz_UZ' => 'uz_Latn_UZ',
  60. 'vai_LR' => 'vai_Latn_LR',
  61. 'zh_CN' => 'zh_Hans_CN',
  62. 'zh_HK' => 'zh_Hans_HK',
  63. 'zh_MO' => 'zh_Hans_MO',
  64. 'zh_SG' => 'zh_Hans_SG',
  65. 'zh_TW' => 'zh_Hant_TW',
  66. );
  67. /**
  68. * Class wide Locale Constants
  69. *
  70. * @var array $_localeData
  71. */
  72. private static $_localeData = array(
  73. 'root' => true,
  74. 'aa' => true,
  75. 'aa_DJ' => true,
  76. 'aa_ER' => true,
  77. 'aa_ET' => true,
  78. 'af' => true,
  79. 'af_NA' => true,
  80. 'af_ZA' => true,
  81. 'agq' => true,
  82. 'agq_CM' => true,
  83. 'ak' => true,
  84. 'ak_GH' => true,
  85. 'am' => true,
  86. 'am_ET' => true,
  87. 'ar' => true,
  88. 'ar_001' => true,
  89. 'ar_AE' => true,
  90. 'ar_BH' => true,
  91. 'ar_DJ' => true,
  92. 'ar_DZ' => true,
  93. 'ar_EG' => true,
  94. 'ar_EH' => true,
  95. 'ar_ER' => true,
  96. 'ar_IL' => true,
  97. 'ar_IQ' => true,
  98. 'ar_JO' => true,
  99. 'ar_KM' => true,
  100. 'ar_KW' => true,
  101. 'ar_LB' => true,
  102. 'ar_LY' => true,
  103. 'ar_MA' => true,
  104. 'ar_MR' => true,
  105. 'ar_OM' => true,
  106. 'ar_PS' => true,
  107. 'ar_QA' => true,
  108. 'ar_SA' => true,
  109. 'ar_SD' => true,
  110. 'ar_SO' => true,
  111. 'ar_SY' => true,
  112. 'ar_TD' => true,
  113. 'ar_TN' => true,
  114. 'ar_YE' => true,
  115. 'as' => true,
  116. 'as_IN' => true,
  117. 'asa' => true,
  118. 'asa_TZ' => true,
  119. 'ast' => true,
  120. 'ast_ES' => true,
  121. 'az' => true,
  122. 'az_Cyrl' => true,
  123. 'az_Cyrl_AZ' => true,
  124. 'az_Latn' => true,
  125. 'az_Latn_AZ' => true,
  126. 'bas' => true,
  127. 'bas_CM' => true,
  128. 'be' => true,
  129. 'be_BY' => true,
  130. 'bem' => true,
  131. 'bem_ZM' => true,
  132. 'bez' => true,
  133. 'bez_TZ' => true,
  134. 'bg' => true,
  135. 'bg_BG' => true,
  136. 'bm' => true,
  137. 'bm_ML' => true,
  138. 'bn' => true,
  139. 'bn_BD' => true,
  140. 'bn_IN' => true,
  141. 'bo' => true,
  142. 'bo_CN' => true,
  143. 'bo_IN' => true,
  144. 'br' => true,
  145. 'br_FR' => true,
  146. 'brx' => true,
  147. 'brx_IN' => true,
  148. 'bs' => true,
  149. 'bs_Cyrl' => true,
  150. 'bs_Cyrl_BA' => true,
  151. 'bs_Latn' => true,
  152. 'bs_Latn_BA' => true,
  153. 'byn' => true,
  154. 'byn_ER' => true,
  155. 'ca' => true,
  156. 'ca_AD' => true,
  157. 'ca_ES' => true,
  158. 'cgg' => true,
  159. 'cgg_UG' => true,
  160. 'chr' => true,
  161. 'chr_US' => true,
  162. 'cs' => true,
  163. 'cs_CZ' => true,
  164. 'cy' => true,
  165. 'cy_GB' => true,
  166. 'da' => true,
  167. 'da_DK' => true,
  168. 'dav' => true,
  169. 'dav_KE' => true,
  170. 'de' => true,
  171. 'de_AT' => true,
  172. 'de_BE' => true,
  173. 'de_CH' => true,
  174. 'de_DE' => true,
  175. 'de_LI' => true,
  176. 'de_LU' => true,
  177. 'dje' => true,
  178. 'dje_NE' => true,
  179. 'dua' => true,
  180. 'dua_CM' => true,
  181. 'dyo' => true,
  182. 'dyo_SN' => true,
  183. 'dz' => true,
  184. 'dz_BT' => true,
  185. 'ebu' => true,
  186. 'ebu_KE' => true,
  187. 'ee' => true,
  188. 'ee_GH' => true,
  189. 'ee_TG' => true,
  190. 'el' => true,
  191. 'el_CY' => true,
  192. 'el_GR' => true,
  193. 'en' => true,
  194. 'en_150' => true,
  195. 'en_AG' => true,
  196. 'en_AS' => true,
  197. 'en_AU' => true,
  198. 'en_BB' => true,
  199. 'en_BE' => true,
  200. 'en_BM' => true,
  201. 'en_BS' => true,
  202. 'en_BW' => true,
  203. 'en_BZ' => true,
  204. 'en_CA' => true,
  205. 'en_CM' => true,
  206. 'en_DM' => true,
  207. 'en_Dsrt' => true,
  208. 'en_Dsrt_US' => true,
  209. 'en_FJ' => true,
  210. 'en_FM' => true,
  211. 'en_GB' => true,
  212. 'en_GD' => true,
  213. 'en_GG' => true,
  214. 'en_GH' => true,
  215. 'en_GI' => true,
  216. 'en_GM' => true,
  217. 'en_GU' => true,
  218. 'en_GY' => true,
  219. 'en_HK' => true,
  220. 'en_IE' => true,
  221. 'en_IM' => true,
  222. 'en_IN' => true,
  223. 'en_JE' => true,
  224. 'en_JM' => true,
  225. 'en_KE' => true,
  226. 'en_KI' => true,
  227. 'en_KN' => true,
  228. 'en_KY' => true,
  229. 'en_LC' => true,
  230. 'en_LR' => true,
  231. 'en_LS' => true,
  232. 'en_MG' => true,
  233. 'en_MH' => true,
  234. 'en_MP' => true,
  235. 'en_MT' => true,
  236. 'en_MU' => true,
  237. 'en_MW' => true,
  238. 'en_NA' => true,
  239. 'en_NG' => true,
  240. 'en_NZ' => true,
  241. 'en_PG' => true,
  242. 'en_PH' => true,
  243. 'en_PK' => true,
  244. 'en_PR' => true,
  245. 'en_PW' => true,
  246. 'en_SB' => true,
  247. 'en_SC' => true,
  248. 'en_SG' => true,
  249. 'en_SL' => true,
  250. 'en_SS' => true,
  251. 'en_SZ' => true,
  252. 'en_TC' => true,
  253. 'en_TO' => true,
  254. 'en_TT' => true,
  255. 'en_TZ' => true,
  256. 'en_UG' => true,
  257. 'en_UM' => true,
  258. 'en_US' => true,
  259. 'en_US_POSIX' => true,
  260. 'en_VC' => true,
  261. 'en_VG' => true,
  262. 'en_VI' => true,
  263. 'en_VU' => true,
  264. 'en_WS' => true,
  265. 'en_ZA' => true,
  266. 'en_ZM' => true,
  267. 'en_ZW' => true,
  268. 'eo' => true,
  269. 'es' => true,
  270. 'es_419' => true,
  271. 'es_AR' => true,
  272. 'es_BO' => true,
  273. 'es_CL' => true,
  274. 'es_CO' => true,
  275. 'es_CR' => true,
  276. 'es_CU' => true,
  277. 'es_DO' => true,
  278. 'es_EA' => true,
  279. 'es_EC' => true,
  280. 'es_ES' => true,
  281. 'es_GQ' => true,
  282. 'es_GT' => true,
  283. 'es_HN' => true,
  284. 'es_IC' => true,
  285. 'es_MX' => true,
  286. 'es_NI' => true,
  287. 'es_PA' => true,
  288. 'es_PE' => true,
  289. 'es_PH' => true,
  290. 'es_PR' => true,
  291. 'es_PY' => true,
  292. 'es_SV' => true,
  293. 'es_US' => true,
  294. 'es_UY' => true,
  295. 'es_VE' => true,
  296. 'et' => true,
  297. 'et_EE' => true,
  298. 'eu' => true,
  299. 'eu_ES' => true,
  300. 'ewo' => true,
  301. 'ewo_CM' => true,
  302. 'fa' => true,
  303. 'fa_AF' => true,
  304. 'fa_IR' => true,
  305. 'ff' => true,
  306. 'ff_SN' => true,
  307. 'fi' => true,
  308. 'fi_FI' => true,
  309. 'fil' => true,
  310. 'fil_PH' => true,
  311. 'fo' => true,
  312. 'fo_FO' => true,
  313. 'fr' => true,
  314. 'fr_BE' => true,
  315. 'fr_BF' => true,
  316. 'fr_BI' => true,
  317. 'fr_BJ' => true,
  318. 'fr_BL' => true,
  319. 'fr_CA' => true,
  320. 'fr_CD' => true,
  321. 'fr_CF' => true,
  322. 'fr_CG' => true,
  323. 'fr_CH' => true,
  324. 'fr_CI' => true,
  325. 'fr_CM' => true,
  326. 'fr_DJ' => true,
  327. 'fr_DZ' => true,
  328. 'fr_FR' => true,
  329. 'fr_GA' => true,
  330. 'fr_GF' => true,
  331. 'fr_GN' => true,
  332. 'fr_GP' => true,
  333. 'fr_GQ' => true,
  334. 'fr_HT' => true,
  335. 'fr_KM' => true,
  336. 'fr_LU' => true,
  337. 'fr_MA' => true,
  338. 'fr_MC' => true,
  339. 'fr_MF' => true,
  340. 'fr_MG' => true,
  341. 'fr_ML' => true,
  342. 'fr_MQ' => true,
  343. 'fr_MR' => true,
  344. 'fr_MU' => true,
  345. 'fr_NC' => true,
  346. 'fr_NE' => true,
  347. 'fr_PF' => true,
  348. 'fr_RE' => true,
  349. 'fr_RW' => true,
  350. 'fr_SC' => true,
  351. 'fr_SN' => true,
  352. 'fr_SY' => true,
  353. 'fr_TD' => true,
  354. 'fr_TG' => true,
  355. 'fr_TN' => true,
  356. 'fr_VU' => true,
  357. 'fr_YT' => true,
  358. 'fur' => true,
  359. 'fur_IT' => true,
  360. 'ga' => true,
  361. 'ga_IE' => true,
  362. 'gd' => true,
  363. 'gd_GB' => true,
  364. 'gl' => true,
  365. 'gl_ES' => true,
  366. 'gsw' => true,
  367. 'gsw_CH' => true,
  368. 'gu' => true,
  369. 'gu_IN' => true,
  370. 'guz' => true,
  371. 'guz_KE' => true,
  372. 'gv' => true,
  373. 'ha' => true,
  374. 'ha_Latn' => true,
  375. 'ha_Latn_GH' => true,
  376. 'ha_Latn_NE' => true,
  377. 'ha_Latn_NG' => true,
  378. 'haw' => true,
  379. 'haw_US' => true,
  380. 'he' => true,
  381. 'he_IL' => true,
  382. 'hi' => true,
  383. 'hi_IN' => true,
  384. 'hr' => true,
  385. 'hr_BA' => true,
  386. 'hr_HR' => true,
  387. 'hu' => true,
  388. 'hu_HU' => true,
  389. 'hy' => true,
  390. 'hy_AM' => true,
  391. 'ia' => true,
  392. 'ia_FR' => true,
  393. 'id' => true,
  394. 'id_ID' => true,
  395. 'ig' => true,
  396. 'ig_NG' => true,
  397. 'ii' => true,
  398. 'ii_CN' => true,
  399. 'is' => true,
  400. 'is_IS' => true,
  401. 'it' => true,
  402. 'it_CH' => true,
  403. 'it_IT' => true,
  404. 'it_SM' => true,
  405. 'ja' => true,
  406. 'ja_JP' => true,
  407. 'jgo' => true,
  408. 'jgo_CM' => true,
  409. 'jmc' => true,
  410. 'jmc_TZ' => true,
  411. 'ka' => true,
  412. 'ka_GE' => true,
  413. 'kab' => true,
  414. 'kab_DZ' => true,
  415. 'kam' => true,
  416. 'kam_KE' => true,
  417. 'kde' => true,
  418. 'kde_TZ' => true,
  419. 'kea' => true,
  420. 'kea_CV' => true,
  421. 'khq' => true,
  422. 'khq_ML' => true,
  423. 'ki' => true,
  424. 'ki_KE' => true,
  425. 'kk' => true,
  426. 'kk_Cyrl' => true,
  427. 'kk_Cyrl_KZ' => true,
  428. 'kkj' => true,
  429. 'kkj_CM' => true,
  430. 'kl' => true,
  431. 'kl_GL' => true,
  432. 'kln' => true,
  433. 'kln_KE' => true,
  434. 'km' => true,
  435. 'km_KH' => true,
  436. 'kn' => true,
  437. 'kn_IN' => true,
  438. 'ko' => true,
  439. 'ko_KP' => true,
  440. 'ko_KR' => true,
  441. 'kok' => true,
  442. 'kok_IN' => true,
  443. 'ks' => true,
  444. 'ks_Arab' => true,
  445. 'ks_Arab_IN' => true,
  446. 'ksb' => true,
  447. 'ksb_TZ' => true,
  448. 'ksf' => true,
  449. 'ksf_CM' => true,
  450. 'ksh' => true,
  451. 'ksh_DE' => true,
  452. 'kw' => true,
  453. 'kw_GB' => true,
  454. 'ky' => true,
  455. 'lag' => true,
  456. 'lag_TZ' => true,
  457. 'lg' => true,
  458. 'lg_UG' => true,
  459. 'ln' => true,
  460. 'ln_AO' => true,
  461. 'ln_CD' => true,
  462. 'ln_CF' => true,
  463. 'ln_CG' => true,
  464. 'lo' => true,
  465. 'lo_LA' => true,
  466. 'lt' => true,
  467. 'lt_LT' => true,
  468. 'lu' => true,
  469. 'lu_CD' => true,
  470. 'luo' => true,
  471. 'luo_KE' => true,
  472. 'luy' => true,
  473. 'luy_KE' => true,
  474. 'lv' => true,
  475. 'lv_LV' => true,
  476. 'mas' => true,
  477. 'mas_KE' => true,
  478. 'mas_TZ' => true,
  479. 'mer' => true,
  480. 'mer_KE' => true,
  481. 'mfe' => true,
  482. 'mfe_MU' => true,
  483. 'mg' => true,
  484. 'mg_MG' => true,
  485. 'mgh' => true,
  486. 'mgh_MZ' => true,
  487. 'mgo' => true,
  488. 'mgo_CM' => true,
  489. 'mk' => true,
  490. 'mk_MK' => true,
  491. 'ml' => true,
  492. 'ml_IN' => true,
  493. 'mn' => true,
  494. 'mn_Cyrl' => true,
  495. 'mn_Cyrl_MN' => true,
  496. 'mr' => true,
  497. 'mr_IN' => true,
  498. 'ms' => true,
  499. 'ms_Latn' => true,
  500. 'ms_Latn_BN' => true,
  501. 'ms_Latn_MY' => true,
  502. 'ms_Latn_SG' => true,
  503. 'mt' => true,
  504. 'mt_MT' => true,
  505. 'mua' => true,
  506. 'mua_CM' => true,
  507. 'my' => true,
  508. 'my_MM' => true,
  509. 'naq' => true,
  510. 'naq_NA' => true,
  511. 'nb' => true,
  512. 'nb_NO' => true,
  513. 'nd' => true,
  514. 'nd_ZW' => true,
  515. 'ne' => true,
  516. 'ne_IN' => true,
  517. 'ne_NP' => true,
  518. 'nl' => true,
  519. 'nl_AW' => true,
  520. 'nl_BE' => true,
  521. 'nl_CW' => true,
  522. 'nl_NL' => true,
  523. 'nl_SR' => true,
  524. 'nl_SX' => true,
  525. 'nmg' => true,
  526. 'nmg_CM' => true,
  527. 'nn' => true,
  528. 'nn_NO' => true,
  529. 'nnh' => true,
  530. 'nnh_CM' => true,
  531. 'nr' => true,
  532. 'nr_ZA' => true,
  533. 'nso' => true,
  534. 'nso_ZA' => true,
  535. 'nus' => true,
  536. 'nus_SD' => true,
  537. 'nyn' => true,
  538. 'nyn_UG' => true,
  539. 'om' => true,
  540. 'om_ET' => true,
  541. 'om_KE' => true,
  542. 'or' => true,
  543. 'or_IN' => true,
  544. 'ordinals' => true,
  545. 'os' => true,
  546. 'os_GE' => true,
  547. 'os_RU' => true,
  548. 'pa' => true,
  549. 'pa_Arab' => true,
  550. 'pa_Arab_PK' => true,
  551. 'pa_Guru' => true,
  552. 'pa_Guru_IN' => true,
  553. 'pl' => true,
  554. 'pl_PL' => true,
  555. 'plurals' => true,
  556. 'ps' => true,
  557. 'ps_AF' => true,
  558. 'pt' => true,
  559. 'pt_AO' => true,
  560. 'pt_BR' => true,
  561. 'pt_CV' => true,
  562. 'pt_GW' => true,
  563. 'pt_MO' => true,
  564. 'pt_MZ' => true,
  565. 'pt_PT' => true,
  566. 'pt_ST' => true,
  567. 'pt_TL' => true,
  568. 'rm' => true,
  569. 'rm_CH' => true,
  570. 'rn' => true,
  571. 'rn_BI' => true,
  572. 'ro' => true,
  573. 'ro_MD' => true,
  574. 'ro_RO' => true,
  575. 'rof' => true,
  576. 'rof_TZ' => true,
  577. 'ru' => true,
  578. 'ru_BY' => true,
  579. 'ru_KG' => true,
  580. 'ru_KZ' => true,
  581. 'ru_MD' => true,
  582. 'ru_RU' => true,
  583. 'ru_UA' => true,
  584. 'rw' => true,
  585. 'rw_RW' => true,
  586. 'rwk' => true,
  587. 'rwk_TZ' => true,
  588. 'sah' => true,
  589. 'sah_RU' => true,
  590. 'saq' => true,
  591. 'saq_KE' => true,
  592. 'sbp' => true,
  593. 'sbp_TZ' => true,
  594. 'se' => true,
  595. 'se_FI' => true,
  596. 'se_NO' => true,
  597. 'seh' => true,
  598. 'seh_MZ' => true,
  599. 'ses' => true,
  600. 'ses_ML' => true,
  601. 'sg' => true,
  602. 'sg_CF' => true,
  603. 'shi' => true,
  604. 'shi_Latn' => true,
  605. 'shi_Latn_MA' => true,
  606. 'shi_Tfng' => true,
  607. 'shi_Tfng_MA' => true,
  608. 'si' => true,
  609. 'si_LK' => true,
  610. 'sk' => true,
  611. 'sk_SK' => true,
  612. 'sl' => true,
  613. 'sl_SI' => true,
  614. 'sn' => true,
  615. 'sn_ZW' => true,
  616. 'so' => true,
  617. 'so_DJ' => true,
  618. 'so_ET' => true,
  619. 'so_KE' => true,
  620. 'so_SO' => true,
  621. 'sq' => true,
  622. 'sq_AL' => true,
  623. 'sq_MK' => true,
  624. 'sq_XK' => true,
  625. 'sr' => true,
  626. 'sr_Cyrl' => true,
  627. 'sr_Cyrl_BA' => true,
  628. 'sr_Cyrl_ME' => true,
  629. 'sr_Cyrl_RS' => true,
  630. 'sr_Cyrl_XK' => true,
  631. 'sr_Latn' => true,
  632. 'sr_Latn_BA' => true,
  633. 'sr_Latn_ME' => true,
  634. 'sr_Latn_RS' => true,
  635. 'sr_Latn_XK' => true,
  636. 'ss' => true,
  637. 'ss_SZ' => true,
  638. 'ss_ZA' => true,
  639. 'ssy' => true,
  640. 'ssy_ER' => true,
  641. 'st' => true,
  642. 'st_LS' => true,
  643. 'st_ZA' => true,
  644. 'sv' => true,
  645. 'sv_AX' => true,
  646. 'sv_FI' => true,
  647. 'sv_SE' => true,
  648. 'sw' => true,
  649. 'sw_KE' => true,
  650. 'sw_TZ' => true,
  651. 'sw_UG' => true,
  652. 'swc' => true,
  653. 'swc_CD' => true,
  654. 'ta' => true,
  655. 'ta_IN' => true,
  656. 'ta_LK' => true,
  657. 'ta_MY' => true,
  658. 'ta_SG' => true,
  659. 'te' => true,
  660. 'te_IN' => true,
  661. 'teo' => true,
  662. 'teo_KE' => true,
  663. 'teo_UG' => true,
  664. 'tg' => true,
  665. 'tg_Cyrl' => true,
  666. 'tg_Cyrl_TJ' => true,
  667. 'th' => true,
  668. 'th_TH' => true,
  669. 'ti' => true,
  670. 'ti_ER' => true,
  671. 'ti_ET' => true,
  672. 'tig' => true,
  673. 'tig_ER' => true,
  674. 'tn' => true,
  675. 'tn_BW' => true,
  676. 'tn_ZA' => true,
  677. 'to' => true,
  678. 'to_TO' => true,
  679. 'tr' => true,
  680. 'tr_CY' => true,
  681. 'tr_TR' => true,
  682. 'ts' => true,
  683. 'ts_ZA' => true,
  684. 'twq' => true,
  685. 'twq_NE' => true,
  686. 'tzm' => true,
  687. 'tzm_Latn' => true,
  688. 'tzm_Latn_MA' => true,
  689. 'uk' => true,
  690. 'uk_UA' => true,
  691. 'ur' => true,
  692. 'ur_IN' => true,
  693. 'ur_PK' => true,
  694. 'uz' => true,
  695. 'uz_Arab' => true,
  696. 'uz_Arab_AF' => true,
  697. 'uz_Cyrl' => true,
  698. 'uz_Cyrl_UZ' => true,
  699. 'uz_Latn' => true,
  700. 'uz_Latn_UZ' => true,
  701. 'vai' => true,
  702. 'vai_Latn' => true,
  703. 'vai_Latn_LR' => true,
  704. 'vai_Vaii' => true,
  705. 'vai_Vaii_LR' => true,
  706. 've' => true,
  707. 've_ZA' => true,
  708. 'vi' => true,
  709. 'vi_VN' => true,
  710. 'vo' => true,
  711. 'vun' => true,
  712. 'vun_TZ' => true,
  713. 'wae' => true,
  714. 'wae_CH' => true,
  715. 'wal' => true,
  716. 'wal_ET' => true,
  717. 'xh' => true,
  718. 'xh_ZA' => true,
  719. 'xog' => true,
  720. 'xog_UG' => true,
  721. 'yav' => true,
  722. 'yav_CM' => true,
  723. 'yo' => true,
  724. 'yo_NG' => true,
  725. 'zh' => true,
  726. 'zh_Hans' => true,
  727. 'zh_Hans_CN' => true,
  728. 'zh_Hans_HK' => true,
  729. 'zh_Hans_MO' => true,
  730. 'zh_Hans_SG' => true,
  731. 'zh_Hant' => true,
  732. 'zh_Hant_HK' => true,
  733. 'zh_Hant_MO' => true,
  734. 'zh_Hant_TW' => true,
  735. 'zu' => true,
  736. 'zu_ZA' => true,
  737. );
  738. /**
  739. * Class wide Locale Constants
  740. *
  741. * @var array $_territoryData
  742. */
  743. private static $_territoryData = array(
  744. 'AD' => 'ca_AD',
  745. 'AE' => 'ar_AE',
  746. 'AF' => 'fa_AF',
  747. 'AG' => 'en_AG',
  748. 'AI' => 'en_AI',
  749. 'AL' => 'sq_AL',
  750. 'AM' => 'hy_AM',
  751. 'AN' => 'pap_AN',
  752. 'AO' => 'pt_AO',
  753. 'AQ' => 'und_AQ',
  754. 'AR' => 'es_AR',
  755. 'AS' => 'sm_AS',
  756. 'AT' => 'de_AT',
  757. 'AU' => 'en_AU',
  758. 'AW' => 'nl_AW',
  759. 'AX' => 'sv_AX',
  760. 'AZ' => 'az_Latn_AZ',
  761. 'BA' => 'bs_BA',
  762. 'BB' => 'en_BB',
  763. 'BD' => 'bn_BD',
  764. 'BE' => 'nl_BE',
  765. 'BF' => 'mos_BF',
  766. 'BG' => 'bg_BG',
  767. 'BH' => 'ar_BH',
  768. 'BI' => 'rn_BI',
  769. 'BJ' => 'fr_BJ',
  770. 'BL' => 'fr_BL',
  771. 'BM' => 'en_BM',
  772. 'BN' => 'ms_BN',
  773. 'BO' => 'es_BO',
  774. 'BR' => 'pt_BR',
  775. 'BS' => 'en_BS',
  776. 'BT' => 'dz_BT',
  777. 'BV' => 'und_BV',
  778. 'BW' => 'en_BW',
  779. 'BY' => 'be_BY',
  780. 'BZ' => 'en_BZ',
  781. 'CA' => 'en_CA',
  782. 'CC' => 'ms_CC',
  783. 'CD' => 'sw_CD',
  784. 'CF' => 'fr_CF',
  785. 'CG' => 'fr_CG',
  786. 'CH' => 'de_CH',
  787. 'CI' => 'fr_CI',
  788. 'CK' => 'en_CK',
  789. 'CL' => 'es_CL',
  790. 'CM' => 'fr_CM',
  791. 'CN' => 'zh_Hans_CN',
  792. 'CO' => 'es_CO',
  793. 'CR' => 'es_CR',
  794. 'CU' => 'es_CU',
  795. 'CV' => 'kea_CV',
  796. 'CX' => 'en_CX',
  797. 'CY' => 'el_CY',
  798. 'CZ' => 'cs_CZ',
  799. 'DE' => 'de_DE',
  800. 'DJ' => 'aa_DJ',
  801. 'DK' => 'da_DK',
  802. 'DM' => 'en_DM',
  803. 'DO' => 'es_DO',
  804. 'DZ' => 'ar_DZ',
  805. 'EC' => 'es_EC',
  806. 'EE' => 'et_EE',
  807. 'EG' => 'ar_EG',
  808. 'EH' => 'ar_EH',
  809. 'ER' => 'ti_ER',
  810. 'ES' => 'es_ES',
  811. 'ET' => 'en_ET',
  812. 'FI' => 'fi_FI',
  813. 'FJ' => 'hi_FJ',
  814. 'FK' => 'en_FK',
  815. 'FM' => 'chk_FM',
  816. 'FO' => 'fo_FO',
  817. 'FR' => 'fr_FR',
  818. 'GA' => 'fr_GA',
  819. 'GB' => 'en_GB',
  820. 'GD' => 'en_GD',
  821. 'GE' => 'ka_GE',
  822. 'GF' => 'fr_GF',
  823. 'GG' => 'en_GG',
  824. 'GH' => 'ak_GH',
  825. 'GI' => 'en_GI',
  826. 'GL' => 'iu_GL',
  827. 'GM' => 'en_GM',
  828. 'GN' => 'fr_GN',
  829. 'GP' => 'fr_GP',
  830. 'GQ' => 'fan_GQ',
  831. 'GR' => 'el_GR',
  832. 'GS' => 'und_GS',
  833. 'GT' => 'es_GT',
  834. 'GU' => 'en_GU',
  835. 'GW' => 'pt_GW',
  836. 'GY' => 'en_GY',
  837. 'HK' => 'zh_Hant_HK',
  838. 'HM' => 'und_HM',
  839. 'HN' => 'es_HN',
  840. 'HR' => 'hr_HR',
  841. 'HT' => 'ht_HT',
  842. 'HU' => 'hu_HU',
  843. 'ID' => 'id_ID',
  844. 'IE' => 'en_IE',
  845. 'IL' => 'he_IL',
  846. 'IM' => 'en_IM',
  847. 'IN' => 'hi_IN',
  848. 'IO' => 'und_IO',
  849. 'IQ' => 'ar_IQ',
  850. 'IR' => 'fa_IR',
  851. 'IS' => 'is_IS',
  852. 'IT' => 'it_IT',
  853. 'JE' => 'en_JE',
  854. 'JM' => 'en_JM',
  855. 'JO' => 'ar_JO',
  856. 'JP' => 'ja_JP',
  857. 'KE' => 'en_KE',
  858. 'KG' => 'ky_Cyrl_KG',
  859. 'KH' => 'km_KH',
  860. 'KI' => 'en_KI',
  861. 'KM' => 'ar_KM',
  862. 'KN' => 'en_KN',
  863. 'KP' => 'ko_KP',
  864. 'KR' => 'ko_KR',
  865. 'KW' => 'ar_KW',
  866. 'KY' => 'en_KY',
  867. 'KZ' => 'ru_KZ',
  868. 'LA' => 'lo_LA',
  869. 'LB' => 'ar_LB',
  870. 'LC' => 'en_LC',
  871. 'LI' => 'de_LI',
  872. 'LK' => 'si_LK',
  873. 'LR' => 'en_LR',
  874. 'LS' => 'st_LS',
  875. 'LT' => 'lt_LT',
  876. 'LU' => 'fr_LU',
  877. 'LV' => 'lv_LV',
  878. 'LY' => 'ar_LY',
  879. 'MA' => 'ar_MA',
  880. 'MC' => 'fr_MC',
  881. 'MD' => 'ro_MD',
  882. 'ME' => 'sr_Latn_ME',
  883. 'MF' => 'fr_MF',
  884. 'MG' => 'mg_MG',
  885. 'MH' => 'mh_MH',
  886. 'MK' => 'mk_MK',
  887. 'ML' => 'bm_ML',
  888. 'MM' => 'my_MM',
  889. 'MN' => 'mn_Cyrl_MN',
  890. 'MO' => 'zh_Hant_MO',
  891. 'MP' => 'en_MP',
  892. 'MQ' => 'fr_MQ',
  893. 'MR' => 'ar_MR',
  894. 'MS' => 'en_MS',
  895. 'MT' => 'mt_MT',
  896. 'MU' => 'mfe_MU',
  897. 'MV' => 'dv_MV',
  898. 'MW' => 'ny_MW',
  899. 'MX' => 'es_MX',
  900. 'MY' => 'ms_MY',
  901. 'MZ' => 'pt_MZ',
  902. 'NA' => 'kj_NA',
  903. 'NC' => 'fr_NC',
  904. 'NE' => 'ha_Latn_NE',
  905. 'NF' => 'en_NF',
  906. 'NG' => 'en_NG',
  907. 'NI' => 'es_NI',
  908. 'NL' => 'nl_NL',
  909. 'NO' => 'nb_NO',
  910. 'NP' => 'ne_NP',
  911. 'NR' => 'en_NR',
  912. 'NU' => 'niu_NU',
  913. 'NZ' => 'en_NZ',
  914. 'OM' => 'ar_OM',
  915. 'PA' => 'es_PA',
  916. 'PE' => 'es_PE',
  917. 'PF' => 'fr_PF',
  918. 'PG' => 'tpi_PG',
  919. 'PH' => 'fil_PH',
  920. 'PK' => 'ur_PK',
  921. 'PL' => 'pl_PL',
  922. 'PM' => 'fr_PM',
  923. 'PN' => 'en_PN',
  924. 'PR' => 'es_PR',
  925. 'PS' => 'ar_PS',
  926. 'PT' => 'pt_PT',
  927. 'PW' => 'pau_PW',
  928. 'PY' => 'gn_PY',
  929. 'QA' => 'ar_QA',
  930. 'RE' => 'fr_RE',
  931. 'RO' => 'ro_RO',
  932. 'RS' => 'sr_Cyrl_RS',
  933. 'RU' => 'ru_RU',
  934. 'RW' => 'rw_RW',
  935. 'SA' => 'ar_SA',
  936. 'SB' => 'en_SB',
  937. 'SC' => 'crs_SC',
  938. 'SD' => 'ar_SD',
  939. 'SE' => 'sv_SE',
  940. 'SG' => 'en_SG',
  941. 'SH' => 'en_SH',
  942. 'SI' => 'sl_SI',
  943. 'SJ' => 'nb_SJ',
  944. 'SK' => 'sk_SK',
  945. 'SL' => 'kri_SL',
  946. 'SM' => 'it_SM',
  947. 'SN' => 'fr_SN',
  948. 'SO' => 'sw_SO',
  949. 'SR' => 'srn_SR',
  950. 'ST' => 'pt_ST',
  951. 'SV' => 'es_SV',
  952. 'SY' => 'ar_SY',
  953. 'SZ' => 'en_SZ',
  954. 'TC' => 'en_TC',
  955. 'TD' => 'fr_TD',
  956. 'TF' => 'und_TF',
  957. 'TG' => 'fr_TG',
  958. 'TH' => 'th_TH',
  959. 'TJ' => 'tg_Cyrl_TJ',
  960. 'TK' => 'tkl_TK',
  961. 'TL' => 'pt_TL',
  962. 'TM' => 'tk_TM',
  963. 'TN' => 'ar_TN',
  964. 'TO' => 'to_TO',
  965. 'TR' => 'tr_TR',
  966. 'TT' => 'en_TT',
  967. 'TV' => 'tvl_TV',
  968. 'TW' => 'zh_Hant_TW',
  969. 'TZ' => 'sw_TZ',
  970. 'UA' => 'uk_UA',
  971. 'UG' => 'sw_UG',
  972. 'UM' => 'en_UM',
  973. 'US' => 'en_US',
  974. 'UY' => 'es_UY',
  975. 'UZ' => 'uz_Cyrl_UZ',
  976. 'VA' => 'it_VA',
  977. 'VC' => 'en_VC',
  978. 'VE' => 'es_VE',
  979. 'VG' => 'en_VG',
  980. 'VI' => 'en_VI',
  981. 'VN' => 'vi_VN',
  982. 'VU' => 'bi_VU',
  983. 'WF' => 'wls_WF',
  984. 'WS' => 'sm_WS',
  985. 'YE' => 'ar_YE',
  986. 'YT' => 'swb_YT',
  987. 'ZA' => 'en_ZA',
  988. 'ZM' => 'en_ZM',
  989. 'ZW' => 'sn_ZW'
  990. );
  991. /**
  992. * Autosearch constants
  993. */
  994. const BROWSER = 'browser';
  995. const ENVIRONMENT = 'environment';
  996. const ZFDEFAULT = 'default';
  997. /**
  998. * Defines if old behaviour should be supported
  999. * Old behaviour throws notices and will be deleted in future releases
  1000. *
  1001. * @var boolean
  1002. */
  1003. public static $compatibilityMode = false;
  1004. /**
  1005. * Internal variable
  1006. *
  1007. * @var boolean
  1008. */
  1009. private static $_breakChain = false;
  1010. /**
  1011. * Actual set locale
  1012. *
  1013. * @var string Locale
  1014. */
  1015. protected $_locale;
  1016. /**
  1017. * Automatic detected locale
  1018. *
  1019. * @var string Locales
  1020. */
  1021. protected static $_auto;
  1022. /**
  1023. * Browser detected locale
  1024. *
  1025. * @var string Locales
  1026. */
  1027. protected static $_browser;
  1028. /**
  1029. * Environment detected locale
  1030. *
  1031. * @var string Locales
  1032. */
  1033. protected static $_environment;
  1034. /**
  1035. * Default locale
  1036. *
  1037. * @var string Locales
  1038. */
  1039. protected static $_default = array('en' => true);
  1040. /**
  1041. * Generates a locale object
  1042. * If no locale is given a automatic search is done
  1043. * Then the most probable locale will be automatically set
  1044. * Search order is
  1045. * 1. Given Locale
  1046. * 2. HTTP Client
  1047. * 3. Server Environment
  1048. * 4. Framework Standard
  1049. *
  1050. * @param string|Zend_Locale $locale (Optional) Locale for parsing input
  1051. * @throws Zend_Locale_Exception When autodetection has been failed
  1052. */
  1053. public function __construct($locale = null)
  1054. {
  1055. $this->setLocale($locale);
  1056. }
  1057. /**
  1058. * Serialization Interface
  1059. *
  1060. * @return string
  1061. */
  1062. public function serialize()
  1063. {
  1064. return serialize($this);
  1065. }
  1066. /**
  1067. * Returns a string representation of the object
  1068. *
  1069. * @return string
  1070. */
  1071. public function toString()
  1072. {
  1073. return (string) $this->_locale;
  1074. }
  1075. /**
  1076. * Returns a string representation of the object
  1077. * Alias for toString
  1078. *
  1079. * @return string
  1080. */
  1081. public function __toString()
  1082. {
  1083. return $this->toString();
  1084. }
  1085. /**
  1086. * Return the default locale
  1087. *
  1088. * @return array Returns an array of all locale string
  1089. */
  1090. public static function getDefault()
  1091. {
  1092. if ((self::$compatibilityMode === true) or (func_num_args() > 0)) {
  1093. if (!self::$_breakChain) {
  1094. self::$_breakChain = true;
  1095. trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
  1096. $params = func_get_args();
  1097. $param = null;
  1098. if (isset($params[0])) {
  1099. $param = $params[0];
  1100. }
  1101. return self::getOrder($param);
  1102. }
  1103. self::$_breakChain = false;
  1104. }
  1105. return self::$_default;
  1106. }
  1107. /**
  1108. * Sets a new default locale which will be used when no locale can be detected
  1109. * If provided you can set a quality between 0 and 1 (or 2 and 100)
  1110. * which represents the percent of quality the browser
  1111. * requested within HTTP
  1112. *
  1113. * @param string|Zend_Locale $locale Locale to set
  1114. * @param float $quality The quality to set from 0 to 1
  1115. * @throws Zend_Locale_Exception When a autolocale was given
  1116. * @throws Zend_Locale_Exception When a unknown locale was given
  1117. * @return void
  1118. */
  1119. public static function setDefault($locale, $quality = 1)
  1120. {
  1121. if (($locale === 'auto') or ($locale === 'root') or ($locale === 'default') or
  1122. ($locale === 'environment') or ($locale === 'browser')) {
  1123. require_once 'Zend/Locale/Exception.php';
  1124. throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
  1125. }
  1126. if (($quality < 0.1) or ($quality > 100)) {
  1127. require_once 'Zend/Locale/Exception.php';
  1128. throw new Zend_Locale_Exception("Quality must be between 0.1 and 100");
  1129. }
  1130. if ($quality > 1) {
  1131. $quality /= 100;
  1132. }
  1133. $locale = self::_prepareLocale($locale);
  1134. if (isset(self::$_localeData[(string) $locale]) === true) {
  1135. self::$_default = array((string) $locale => $quality);
  1136. } else {
  1137. $elocale = explode('_', (string) $locale);
  1138. if (isset(self::$_localeData[$elocale[0]]) === true) {
  1139. self::$_default = array($elocale[0] => $quality);
  1140. } else {
  1141. require_once 'Zend/Locale/Exception.php';
  1142. throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
  1143. }
  1144. }
  1145. self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
  1146. }
  1147. /**
  1148. * Expects the Systems standard locale
  1149. *
  1150. * For Windows:
  1151. * f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C
  1152. * would be recognised as de_AT
  1153. *
  1154. * @return array
  1155. */
  1156. public static function getEnvironment()
  1157. {
  1158. if (self::$_environment !== null) {
  1159. return self::$_environment;
  1160. }
  1161. require_once 'Zend/Locale/Data/Translation.php';
  1162. $language = setlocale(LC_ALL, 0);
  1163. $languages = explode(';', $language);
  1164. $languagearray = array();
  1165. foreach ($languages as $locale) {
  1166. if (strpos($locale, '=') !== false) {
  1167. $language = substr($locale, strpos($locale, '='));
  1168. $language = substr($language, 1);
  1169. }
  1170. if ($language !== 'C') {
  1171. if (strpos($language, '.') !== false) {
  1172. $language = substr($language, 0, strpos($language, '.'));
  1173. } else if (strpos($language, '@') !== false) {
  1174. $language = substr($language, 0, strpos($language, '@'));
  1175. }
  1176. $language = str_ireplace(
  1177. array_keys(Zend_Locale_Data_Translation::$languageTranslation),
  1178. array_values(Zend_Locale_Data_Translation::$languageTranslation),
  1179. (string) $language
  1180. );
  1181. $language = str_ireplace(
  1182. array_keys(Zend_Locale_Data_Translation::$regionTranslation),
  1183. array_values(Zend_Locale_Data_Translation::$regionTranslation),
  1184. $language
  1185. );
  1186. if (isset(self::$_localeData[$language]) === true) {
  1187. $languagearray[$language] = 1;
  1188. if (strpos($language, '_') !== false) {
  1189. $languagearray[substr($language, 0, strpos($language, '_'))] = 1;
  1190. }
  1191. }
  1192. }
  1193. }
  1194. self::$_environment = $languagearray;
  1195. return $languagearray;
  1196. }
  1197. /**
  1198. * Return an array of all accepted languages of the client
  1199. * Expects RFC compilant Header !!
  1200. *
  1201. * The notation can be :
  1202. * de,en-UK-US;q=0.5,fr-FR;q=0.2
  1203. *
  1204. * @return array - list of accepted languages including quality
  1205. */
  1206. public static function getBrowser()
  1207. {
  1208. if (self::$_browser !== null) {
  1209. return self::$_browser;
  1210. }
  1211. $httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
  1212. if (empty($httplanguages) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
  1213. $httplanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  1214. }
  1215. $languages = array();
  1216. if (empty($httplanguages)) {
  1217. return $languages;
  1218. }
  1219. $accepted = preg_split('/,\s*/', $httplanguages);
  1220. foreach ($accepted as $accept) {
  1221. $match = null;
  1222. $result = preg_match('/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
  1223. $accept, $match);
  1224. if ($result < 1) {
  1225. continue;
  1226. }
  1227. if (isset($match[2]) === true) {
  1228. $quality = (float) $match[2];
  1229. } else {
  1230. $quality = 1.0;
  1231. }
  1232. $countrys = explode('-', $match[1]);
  1233. $region = array_shift($countrys);
  1234. $country2 = explode('_', $region);
  1235. $region = array_shift($country2);
  1236. foreach ($countrys as $country) {
  1237. $languages[$region . '_' . strtoupper($country)] = $quality;
  1238. }
  1239. foreach ($country2 as $country) {
  1240. $languages[$region . '_' . strtoupper($country)] = $quality;
  1241. }
  1242. if ((isset($languages[$region]) === false) || ($languages[$region] < $quality)) {
  1243. $languages[$region] = $quality;
  1244. }
  1245. }
  1246. self::$_browser = $languages;
  1247. return $languages;
  1248. }
  1249. /**
  1250. * Sets a new locale
  1251. *
  1252. * @param string|Zend_Locale $locale (Optional) New locale to set
  1253. * @return void
  1254. */
  1255. public function setLocale($locale = null)
  1256. {
  1257. $locale = self::_prepareLocale($locale);
  1258. if (isset(self::$_localeData[(string) $locale]) === false) {
  1259. // Is it an alias? If so, we can use this locale
  1260. if (isset(self::$_localeAliases[$locale]) === true) {
  1261. $this->_locale = $locale;
  1262. return;
  1263. }
  1264. $region = substr((string) $locale, 0, 3);
  1265. if (isset($region[2]) === true) {
  1266. if (($region[2] === '_') or ($region[2] === '-')) {
  1267. $region = substr($region, 0, 2);
  1268. }
  1269. }
  1270. if (isset(self::$_localeData[(string) $region]) === true) {
  1271. $this->_locale = $region;
  1272. } else {
  1273. $this->_locale = 'root';
  1274. }
  1275. } else {
  1276. $this->_locale = $locale;
  1277. }
  1278. }
  1279. /**
  1280. * Returns the language part of the locale
  1281. *
  1282. * @return string
  1283. */
  1284. public function getLanguage()
  1285. {
  1286. $locale = explode('_', $this->_locale);
  1287. return $locale[0];
  1288. }
  1289. /**
  1290. * Returns the region part of the locale if available
  1291. *
  1292. * @return string|false - Regionstring
  1293. */
  1294. public function getRegion()
  1295. {
  1296. $locale = explode('_', $this->_locale);
  1297. if (isset($locale[1]) === true) {
  1298. return $locale[1];
  1299. }
  1300. return false;
  1301. }
  1302. /**
  1303. * Return the accepted charset of the client
  1304. *
  1305. * @return string
  1306. */
  1307. public static function getHttpCharset()
  1308. {
  1309. $httpcharsets = getenv('HTTP_ACCEPT_CHARSET');
  1310. $charsets = array();
  1311. if ($httpcharsets === false) {
  1312. return $charsets;
  1313. }
  1314. $accepted = preg_split('/,\s*/', $httpcharsets);
  1315. foreach ($accepted as $accept) {
  1316. if (empty($accept) === true) {
  1317. continue;
  1318. }
  1319. if (strpos($accept, ';') !== false) {
  1320. $quality = (float) substr($accept, (strpos($accept, '=') + 1));
  1321. $pos = substr($accept, 0, strpos($accept, ';'));
  1322. $charsets[$pos] = $quality;
  1323. } else {
  1324. $quality = 1.0;
  1325. $charsets[$accept] = $quality;
  1326. }
  1327. }
  1328. return $charsets;
  1329. }
  1330. /**
  1331. * Returns true if both locales are equal
  1332. *
  1333. * @param Zend_Locale $object Locale to check for equality
  1334. * @return boolean
  1335. */
  1336. public function equals(Zend_Locale $object)
  1337. {
  1338. if ($object->toString() === $this->toString()) {
  1339. return true;
  1340. }
  1341. return false;
  1342. }
  1343. /**
  1344. * Returns localized informations as array, supported are several
  1345. * types of informations.
  1346. * For detailed information about the types look into the documentation
  1347. *
  1348. * @param string $path (Optional) Type of information to return
  1349. * @param string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
  1350. * @param string $value (Optional) Value for detail list
  1351. * @return array Array with the wished information in the given language
  1352. */
  1353. public static function getTranslationList($path = null, $locale = null, $value = null)
  1354. {
  1355. require_once 'Zend/Locale/Data.php';
  1356. $locale = self::findLocale($locale);
  1357. $result = Zend_Locale_Data::getList($locale, $path, $value);
  1358. if (empty($result) === true) {
  1359. return false;
  1360. }
  1361. return $result;
  1362. }
  1363. /**
  1364. * Returns an array with the name of all languages translated to the given language
  1365. *
  1366. * @param string|Zend_Locale $locale (Optional) Locale for language translation
  1367. * @return array
  1368. * @deprecated
  1369. */
  1370. public static function getLanguageTranslationList($locale = null)
  1371. {
  1372. trigger_error("The method getLanguageTranslationList is deprecated. Use getTranslationList('language', $locale) instead", E_USER_NOTICE);
  1373. return self::getTranslationList('language', $locale);
  1374. }
  1375. /**
  1376. * Returns an array with the name of all scripts translated to the given language
  1377. *
  1378. * @param string|Zend_Locale $locale (Optional) Locale for script translation
  1379. * @return array
  1380. * @deprecated
  1381. */
  1382. public static function getScriptTranslationList($locale = null)
  1383. {
  1384. trigger_error("The method getScriptTranslationList is deprecated. Use getTranslationList('script', $locale) instead", E_USER_NOTICE);
  1385. return self::getTranslationList('script', $locale);
  1386. }
  1387. /**
  1388. * Returns an array with the name of all countries translated to the given language
  1389. *
  1390. * @param string|Zend_Locale $locale (Optional) Locale for country translation
  1391. * @return array
  1392. * @deprecated
  1393. */
  1394. public static function getCountryTranslationList($locale = null)
  1395. {
  1396. trigger_error("The method getCountryTranslationList is deprecated. Use getTranslationList('territory', $locale, 2) instead", E_USER_NOTICE);
  1397. return self::getTranslationList('territory', $locale, 2);
  1398. }
  1399. /**
  1400. * Returns an array with the name of all territories translated to the given language
  1401. * All territories contains other countries.
  1402. *
  1403. * @param string|Zend_Locale $locale (Optional) Locale for territory translation
  1404. * @return array
  1405. * @deprecated
  1406. */
  1407. public static function getTerritoryTranslationList($locale = null)
  1408. {
  1409. trigger_error("The method getTerritoryTranslationList is deprecated. Use getTranslationList('territory', $locale, 1) instead", E_USER_NOTICE);
  1410. return self::getTranslationList('territory', $locale, 1);
  1411. }
  1412. /**
  1413. * Returns a localized information string, supported are several types of informations.
  1414. * For detailed information about the types look into the documentation
  1415. *
  1416. * @param string $value Name to get detailed information about
  1417. * @param string $path (Optional) Type of information to return
  1418. * @param string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
  1419. * @return string|false The wished information in the given language
  1420. */
  1421. public static function getTranslation($value = null, $path = null, $locale = null)
  1422. {
  1423. require_once 'Zend/Locale/Data.php';
  1424. $locale = self::findLocale($locale);
  1425. $result = Zend_Locale_Data::getContent($locale, $path, $value);
  1426. if (empty($result) === true && '0' !== $result) {
  1427. return false;
  1428. }
  1429. return $result;
  1430. }
  1431. /**
  1432. * Returns the localized language name
  1433. *
  1434. * @param string $value Name to get detailed information about
  1435. * @param string $locale (Optional) Locale for language translation
  1436. * @return array
  1437. * @deprecated
  1438. */
  1439. public static function getLanguageTranslation($value, $locale = null)
  1440. {
  1441. trigger_error("The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead", E_USER_NOTICE);
  1442. return self::getTranslation($value, 'language', $locale);
  1443. }
  1444. /**
  1445. * Returns the localized script name
  1446. *
  1447. * @param string $value Name to get detailed information about
  1448. * @param string $locale (Optional) locale for script translation
  1449. * @return array
  1450. * @deprecated
  1451. */
  1452. public static function getScriptTranslation($value, $locale = null)
  1453. {
  1454. trigger_error("The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead", E_USER_NOTICE);
  1455. return self::getTranslation($value, 'script', $locale);
  1456. }
  1457. /**
  1458. * Returns the localized country name
  1459. *
  1460. * @param string $value Name to get detailed information about
  1461. * @param string|Zend_Locale $locale (Optional) Locale for country translation
  1462. * @return array
  1463. * @deprecated
  1464. */
  1465. public static function getCountryTranslation($value, $locale = null)
  1466. {
  1467. trigger_error("The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead", E_USER_NOTICE);
  1468. return self::getTranslation($value, 'country', $locale);
  1469. }
  1470. /**
  1471. * Returns the localized territory name
  1472. * All territories contains other countries.
  1473. *
  1474. * @param string $value Name to get detailed information about
  1475. * @param string|Zend_Locale $locale (Optional) Locale for territory translation
  1476. * @return array
  1477. * @deprecated
  1478. */
  1479. public static function getTerritoryTranslation($value, $locale = null)
  1480. {
  1481. trigger_error("The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead", E_USER_NOTICE);
  1482. return self::getTranslation($value, 'territory', $locale);
  1483. }
  1484. /**
  1485. * Returns an array with translated yes strings
  1486. *
  1487. * @param string|Zend_Locale $locale (Optional) Locale for language translation (defaults to $this locale)
  1488. * @return array
  1489. */
  1490. public static function getQuestion($locale = null)
  1491. {
  1492. require_once 'Zend/Locale/Data.php';
  1493. $locale = self::findLocale($locale);
  1494. $quest = Zend_Locale_Data::getList($locale, 'question');
  1495. $yes = explode(':', $quest['yes']);
  1496. $no = explode(':', $quest['no']);
  1497. $quest['yes'] = $yes[0];
  1498. $quest['yesarray'] = $yes;
  1499. $quest['no'] = $no[0];
  1500. $quest['noarray'] = $no;
  1501. $quest['yesexpr'] = self::_prepareQuestionString($yes);
  1502. $quest['noexpr'] = self::_prepareQuestionString($no);
  1503. return $quest;
  1504. }
  1505. /**
  1506. * Internal function for preparing the returned question regex string
  1507. *
  1508. * @param string $input Regex to parse
  1509. * @return string
  1510. */
  1511. private static function _prepareQuestionString($input)
  1512. {
  1513. $regex = '';
  1514. if (is_array($input) === true) {
  1515. $regex = '^';
  1516. $start = true;
  1517. foreach ($input as $row) {
  1518. if ($start === false) {
  1519. $regex .= '|';
  1520. }
  1521. $start = false;
  1522. $regex .= '(';
  1523. $one = null;
  1524. if (strlen($row) > 2) {
  1525. $one = true;
  1526. }
  1527. foreach (str_split($row, 1) as $char) {
  1528. $regex .= '[' . $char;
  1529. $regex .= strtoupper($char) . ']';
  1530. if ($one === true) {
  1531. $one = false;
  1532. $regex .= '(';
  1533. }
  1534. }
  1535. if ($one === false) {
  1536. $regex .= ')';
  1537. }
  1538. $regex .= '?)';
  1539. }
  1540. }
  1541. return $regex;
  1542. }
  1543. /**
  1544. * Checks if a locale identifier is a real locale or not
  1545. * Examples:
  1546. * "en_XX" refers to "en", which returns true
  1547. * "XX_yy" refers to "root", which returns false
  1548. *
  1549. * @param string|Zend_Locale $locale Locale to check for
  1550. * @param boolean $strict (Optional) If true, no rerouting will be done when checking
  1551. * @param boolean $compatible (DEPRECATED) Only for internal usage, brakes compatibility mode
  1552. * @return boolean If the locale is known dependend on the settings
  1553. */
  1554. public static function isLocale($locale, $strict = false, $compatible = true)
  1555. {
  1556. if (($locale instanceof Zend_Locale)
  1557. || (is_string($locale) && array_key_exists($locale, self::$_localeData))
  1558. ) {
  1559. return true;
  1560. }
  1561. // Is it an alias?
  1562. if (is_string($locale) && array_key_exists($locale, self::$_localeAliases)) {
  1563. return true;
  1564. }
  1565. if (($locale === null) || (!is_string($locale) and !is_array($locale))) {
  1566. return false;
  1567. }
  1568. try {
  1569. $locale = self::_prepareLocale($locale, $strict);
  1570. } catch (Zend_Locale_Exception $e) {
  1571. return false;
  1572. }
  1573. if (($compatible === true) and (self::$compatibilityMode === true)) {
  1574. trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
  1575. if (isset(self::$_localeData[$locale]) === true) {
  1576. return $locale;
  1577. } else if (!$strict) {
  1578. $locale = explode('_', $locale);
  1579. if (isset(self::$_localeData[$locale[0]]) === true) {
  1580. return $locale[0];
  1581. }
  1582. }
  1583. } else {
  1584. if (isset(self::$_localeData[$locale]) === true) {
  1585. return true;
  1586. } else if (!$strict) {
  1587. $locale = explode('_', $locale);
  1588. if (isset(self::$_localeData[$locale[0]]) === true) {
  1589. return true;
  1590. }
  1591. }
  1592. }
  1593. return false;
  1594. }
  1595. /**
  1596. * Finds the proper locale based on the input
  1597. * Checks if it exists, degrades it when necessary
  1598. * Detects registry locale and when all fails tries to detect a automatic locale
  1599. * Returns the found locale as string
  1600. *
  1601. * @param string $locale
  1602. * @throws Zend_Locale_Exception When the given locale is no locale or the autodetection fails
  1603. * @return string
  1604. */
  1605. public static function findLocale($locale = null)
  1606. {
  1607. if ($locale === null) {
  1608. require_once 'Zend/Registry.php';
  1609. if (Zend_Registry::isRegistered('Zend_Locale')) {
  1610. $locale = Zend_Registry::get('Zend_Locale');
  1611. }
  1612. }
  1613. if ($locale === null) {
  1614. $locale = new Zend_Locale();
  1615. }
  1616. if (!Zend_Locale::isLocale($locale, true, false)) {
  1617. if (!Zend_Locale::isLocale($locale, false, false)) {
  1618. $locale = Zend_Locale::getLocaleToTerritory($locale);
  1619. if (empty($locale)) {
  1620. require_once 'Zend/Locale/Exception.php';
  1621. throw new Zend_Locale_Exception("The locale '$locale' is no known locale");
  1622. }
  1623. } else {
  1624. $locale = new Zend_Locale($locale);
  1625. }
  1626. }
  1627. $locale = self::_prepareLocale($locale);
  1628. return $locale;
  1629. }
  1630. /**
  1631. * Returns the expected locale for a given territory
  1632. *
  1633. * @param string $territory Territory for which the locale is being searched
  1634. * @return string|null Locale string or null when no locale has been found
  1635. */
  1636. public static function getLocaleToTerritory($territory)
  1637. {
  1638. $territory = strtoupper($territory);
  1639. if (array_key_exists($territory, self::$_territoryData)) {
  1640. return self::$_territoryData[$territory];
  1641. }
  1642. return null;
  1643. }
  1644. /**
  1645. * Returns a list of all known locales where the locale is the key
  1646. * Only real locales are returned, the internal locales 'root', 'auto', 'browser'
  1647. * and 'environment' are suppressed
  1648. *
  1649. * @return array List of all Locales
  1650. */
  1651. public static function getLocaleList()
  1652. {
  1653. $list = self::$_localeData;
  1654. unset($list['root']);
  1655. unset($list['auto']);
  1656. unset($list['browser']);
  1657. unset($list['environment']);
  1658. return $list;
  1659. }
  1660. /**
  1661. * Returns the set cache
  1662. *
  1663. * @return Zend_Cache_Core The set cache
  1664. */
  1665. public static function getCache()
  1666. {
  1667. require_once 'Zend/Locale/Data.php';
  1668. return Zend_Locale_Data::getCache();
  1669. }
  1670. /**
  1671. * Sets a cache
  1672. *
  1673. * @param Zend_Cache_Core $cache Cache to set
  1674. * @return void
  1675. */
  1676. public static function setCache(Zend_Cache_Core $cache)
  1677. {
  1678. require_once 'Zend/Locale/Data.php';
  1679. Zend_Locale_Data::setCache($cache);
  1680. }
  1681. /**
  1682. * Returns true when a cache is set
  1683. *
  1684. * @return boolean
  1685. */
  1686. public static function hasCache()
  1687. {
  1688. require_once 'Zend/Locale/Data.php';
  1689. return Zend_Locale_Data::hasCache();
  1690. }
  1691. /**
  1692. * Removes any set cache
  1693. *
  1694. * @return void
  1695. */
  1696. public static function removeCache()
  1697. {
  1698. require_once 'Zend/Locale/Data.php';
  1699. Zend_Locale_Data::removeCache();
  1700. }
  1701. /**
  1702. * Clears all set cache data
  1703. *
  1704. * @param string $tag Tag to clear when the default tag name is not used
  1705. * @return void
  1706. */
  1707. public static function clearCache($tag = null)
  1708. {
  1709. require_once 'Zend/Locale/Data.php';
  1710. Zend_Locale_Data::clearCache($tag);
  1711. }
  1712. /**
  1713. * Disables the set cache
  1714. *
  1715. * @param boolean $flag True disables any set cache, default is false
  1716. * @return void
  1717. */
  1718. public static function disableCache($flag)
  1719. {
  1720. require_once 'Zend/Locale/Data.php';
  1721. Zend_Locale_Data::disableCache($flag);
  1722. }
  1723. /**
  1724. * Internal function, returns a single locale on detection
  1725. *
  1726. * @param string|Zend_Locale $locale (Optional) Locale to work on
  1727. * @param boolean $strict (Optional) Strict preparation
  1728. * @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended
  1729. * @return string
  1730. */
  1731. private static function _prepareLocale($locale, $strict = false)
  1732. {
  1733. if ($locale instanceof Zend_Locale) {
  1734. $locale = $locale->toString();
  1735. }
  1736. if (is_array($locale)) {
  1737. return '';
  1738. }
  1739. if (empty(self::$_auto) === true) {
  1740. self::$_browser = self::getBrowser();
  1741. self::$_environment = self::getEnvironment();
  1742. self::$_breakChain = true;
  1743. self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
  1744. }
  1745. if (!$strict) {
  1746. if ($locale === 'browser') {
  1747. $locale = self::$_browser;
  1748. }
  1749. if ($locale === 'environment') {
  1750. $locale = self::$_environment;
  1751. }
  1752. if ($locale === 'default') {
  1753. $locale = self::$_default;
  1754. }
  1755. if (($locale === 'auto') or ($locale === null)) {
  1756. $locale = self::$_auto;
  1757. }
  1758. if (is_array($locale) === true) {
  1759. $locale = key($locale);
  1760. }
  1761. }
  1762. // This can only happen when someone extends Zend_Locale and erases the default
  1763. if ($locale === null) {
  1764. require_once 'Zend/Locale/Exception.php';
  1765. throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
  1766. }
  1767. if (strpos($locale, '-') !== false) {
  1768. $locale = strtr($locale, '-', '_');
  1769. }
  1770. $parts = explode('_', $locale);
  1771. if (!isset(self::$_localeData[$parts[0]])) {
  1772. if ((count($parts) == 1) && array_key_exists($parts[0], self::$_territoryData)) {
  1773. return self::$_territoryData[$parts[0]];
  1774. }
  1775. return '';
  1776. }
  1777. foreach($parts as $key => $value) {
  1778. if ((strlen($value) < 2) || (strlen($value) > 3)) {
  1779. unset($parts[$key]);
  1780. }
  1781. }
  1782. $locale = implode('_', $parts);
  1783. return (string) $locale;
  1784. }
  1785. /**
  1786. * Search the locale automatically and return all used locales
  1787. * ordered by quality
  1788. *
  1789. * Standard Searchorder is Browser, Environment, Default
  1790. *
  1791. * @param string $searchorder (Optional) Searchorder
  1792. * @return array Returns an array of all detected locales
  1793. */
  1794. public static function getOrder($order = null)
  1795. {
  1796. switch ($order) {
  1797. case self::ENVIRONMENT:
  1798. self::$_breakChain = true;
  1799. $languages = self::getEnvironment() + self::getBrowser() + self::getDefault();
  1800. break;
  1801. case self::ZFDEFAULT:
  1802. self::$_breakChain = true;
  1803. $languages = self::getDefault() + self::getEnvironment() + self::getBrowser();
  1804. break;
  1805. default:
  1806. self::$_breakChain = true;
  1807. $languages = self::getBrowser() + self::getEnvironment() + self::getDefault();
  1808. break;
  1809. }
  1810. return $languages;
  1811. }
  1812. /**
  1813. * Is the given locale in the list of aliases?
  1814. *
  1815. * @param string|Zend_Locale $locale Locale to work on
  1816. * @return boolean
  1817. */
  1818. public static function isAlias($locale)
  1819. {
  1820. if ($locale instanceof Zend_Locale) {
  1821. $locale = $locale->toString();
  1822. }
  1823. return isset(self::$_localeAliases[$locale]);
  1824. }
  1825. /**
  1826. * Return an alias' actual locale.
  1827. *
  1828. * @param string|Zend_Locale $locale Locale to work on
  1829. * @return string
  1830. */
  1831. public static function getAlias($locale)
  1832. {
  1833. if ($locale instanceof Zend_Locale) {
  1834. $locale = $locale->toString();
  1835. }
  1836. if (isset(self::$_localeAliases[$locale]) === true) {
  1837. return self::$_localeAliases[$locale];
  1838. }
  1839. return (string) $locale;
  1840. }
  1841. }