Locale.php 52 KB

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