Locale.php 60 KB

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