File indexing completed on 2024-04-28 06:00:02

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category  Zend
0016  * @package   Zend_Locale
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license   http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version   $Id$
0020  */
0021 
0022 /**
0023  * Base class for localization
0024  *
0025  * @category  Zend
0026  * @package   Zend_Locale
0027  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0028  * @license   http://framework.zend.com/license/new-bsd     New BSD License
0029  */
0030 class Zend_Locale
0031 {
0032     /**
0033      * List of locales that are no longer part of CLDR along with a
0034      * mapping to an appropriate alternative.
0035      *
0036      * @var array
0037      */
0038     private static $_localeAliases = array(
0039         'az_AZ'  => 'az_Latn_AZ',
0040         'bs_BA'  => 'bs_Latn_BA',
0041         'ha_GH'  => 'ha_Latn_GH',
0042         'ha_NE'  => 'ha_Latn_NE',
0043         'ha_NG'  => 'ha_Latn_NG',
0044         'kk_KZ'  => 'kk_Cyrl_KZ',
0045         'ks_IN'  => 'ks_Arab_IN',
0046         'mn_MN'  => 'mn_Cyrl_MN',
0047         'ms_BN'  => 'ms_Latn_BN',
0048         'ms_MY'  => 'ms_Latn_MY',
0049         'ms_SG'  => 'ms_Latn_SG',
0050         'pa_IN'  => 'pa_Guru_IN',
0051         'pa_PK'  => 'pa_Arab_PK',
0052         'shi_MA' => 'shi_Latn_MA',
0053         'sr_BA'  => 'sr_Latn_BA',
0054         'sr_ME'  => 'sr_Latn_ME',
0055         'sr_RS'  => 'sr_Latn_RS',
0056         'sr_XK'  => 'sr_Latn_XK',
0057         'tg_TJ'  => 'tg_Cyrl_TJ',
0058         'tzm_MA' => 'tzm_Latn_MA',
0059         'uz_AF'  => 'uz_Arab_AF',
0060         'uz_UZ'  => 'uz_Latn_UZ',
0061         'vai_LR' => 'vai_Latn_LR',
0062         'zh_CN' => 'zh_Hans_CN',
0063         'zh_HK' => 'zh_Hant_HK',
0064         'zh_MO' => 'zh_Hans_MO',
0065         'zh_SG' => 'zh_Hans_SG',
0066         'zh_TW' => 'zh_Hant_TW',
0067     );
0068 
0069     /**
0070      * Class wide Locale Constants
0071      *
0072      * @var array $_localeData
0073      */
0074     private static $_localeData = array(
0075         'root'        => true,
0076         'aa'          => true,
0077         'aa_DJ'       => true,
0078         'aa_ER'       => true,
0079         'aa_ET'       => true,
0080         'af'          => true,
0081         'af_NA'       => true,
0082         'af_ZA'       => true,
0083         'agq'         => true,
0084         'agq_CM'      => true,
0085         'ak'          => true,
0086         'ak_GH'       => true,
0087         'am'          => true,
0088         'am_ET'       => true,
0089         'ar'          => true,
0090         'ar_001'      => true,
0091         'ar_AE'       => true,
0092         'ar_BH'       => true,
0093         'ar_DJ'       => true,
0094         'ar_DZ'       => true,
0095         'ar_EG'       => true,
0096         'ar_EH'       => true,
0097         'ar_ER'       => true,
0098         'ar_IL'       => true,
0099         'ar_IQ'       => true,
0100         'ar_JO'       => true,
0101         'ar_KM'       => true,
0102         'ar_KW'       => true,
0103         'ar_LB'       => true,
0104         'ar_LY'       => true,
0105         'ar_MA'       => true,
0106         'ar_MR'       => true,
0107         'ar_OM'       => true,
0108         'ar_PS'       => true,
0109         'ar_QA'       => true,
0110         'ar_SA'       => true,
0111         'ar_SD'       => true,
0112         'ar_SO'       => true,
0113         'ar_SS'       => true,
0114         'ar_SY'       => true,
0115         'ar_TD'       => true,
0116         'ar_TN'       => true,
0117         'ar_YE'       => true,
0118         'as'          => true,
0119         'as_IN'       => true,
0120         'asa'         => true,
0121         'asa_TZ'      => true,
0122         'ast'         => true,
0123         'ast_ES'      => true,
0124         'az'          => true,
0125         'az_Cyrl'     => true,
0126         'az_Cyrl_AZ'  => true,
0127         'az_Latn'     => true,
0128         'az_Latn_AZ'  => true,
0129         'bas'         => true,
0130         'bas_CM'      => true,
0131         'be'          => true,
0132         'be_BY'       => true,
0133         'bem'         => true,
0134         'bem_ZM'      => true,
0135         'bez'         => true,
0136         'bez_TZ'      => true,
0137         'bg'          => true,
0138         'bg_BG'       => true,
0139         'bm'          => true,
0140         'bm_ML'       => true,
0141         'bn'          => true,
0142         'bn_BD'       => true,
0143         'bn_IN'       => true,
0144         'bo'          => true,
0145         'bo_CN'       => true,
0146         'bo_IN'       => true,
0147         'br'          => true,
0148         'br_FR'       => true,
0149         'brx'         => true,
0150         'brx_IN'      => true,
0151         'bs'          => true,
0152         'bs_Cyrl'     => true,
0153         'bs_Cyrl_BA'  => true,
0154         'bs_Latn'     => true,
0155         'bs_Latn_BA'  => true,
0156         'byn'         => true,
0157         'byn_ER'      => true,
0158         'ca'          => true,
0159         'ca_AD'       => true,
0160         'ca_ES'       => true,
0161         'ca_ES_VALENCIA' => true,
0162         'ca_FR'       => true,
0163         'ca_IT'       => true,
0164         'cgg'         => true,
0165         'cgg_UG'      => true,
0166         'chr'         => true,
0167         'chr_US'      => true,
0168         'cs'          => true,
0169         'cs_CZ'       => true,
0170         'cy'          => true,
0171         'cy_GB'       => true,
0172         'da'          => true,
0173         'da_DK'       => true,
0174         'da_GL'       => true,
0175         'dav'         => true,
0176         'dav_KE'      => true,
0177         'de'          => true,
0178         'de_AT'       => true,
0179         'de_BE'       => true,
0180         'de_CH'       => true,
0181         'de_DE'       => true,
0182         'de_LI'       => true,
0183         'de_LU'       => true,
0184         'dje'         => true,
0185         'dje_NE'      => true,
0186         'dua'         => true,
0187         'dua_CM'      => true,
0188         'dyo'         => true,
0189         'dyo_SN'      => true,
0190         'dz'          => true,
0191         'dz_BT'       => true,
0192         'ebu'         => true,
0193         'ebu_KE'      => true,
0194         'ee'          => true,
0195         'ee_GH'       => true,
0196         'ee_TG'       => true,
0197         'el'          => true,
0198         'el_CY'       => true,
0199         'el_GR'       => true,
0200         'en'          => true,
0201         'en_001'      => true,
0202         'en_150'      => true,
0203         'en_AG'       => true,
0204         'en_AI'       => true,
0205         'en_AS'       => true,
0206         'en_AU'       => true,
0207         'en_BB'       => true,
0208         'en_BE'       => true,
0209         'en_BM'       => true,
0210         'en_BS'       => true,
0211         'en_BW'       => true,
0212         'en_BZ'       => true,
0213         'en_CA'       => true,
0214         'en_CC'       => true,
0215         'en_CK'       => true,
0216         'en_CM'       => true,
0217         'en_CX'       => true,
0218         'en_DG'       => true,
0219         'en_DM'       => true,
0220         'en_Dsrt'     => true,
0221         'en_Dsrt_US'  => true,
0222         'en_ER'       => true,
0223         'en_FJ'       => true,
0224         'en_FK'       => true,
0225         'en_FM'       => true,
0226         'en_GB'       => true,
0227         'en_GD'       => true,
0228         'en_GG'       => true,
0229         'en_GH'       => true,
0230         'en_GI'       => true,
0231         'en_GM'       => true,
0232         'en_GU'       => true,
0233         'en_GY'       => true,
0234         'en_HK'       => true,
0235         'en_IE'       => true,
0236         'en_IM'       => true,
0237         'en_IN'       => true,
0238         'en_IO'       => true,
0239         'en_JE'       => true,
0240         'en_JM'       => true,
0241         'en_KE'       => true,
0242         'en_KI'       => true,
0243         'en_KN'       => true,
0244         'en_KY'       => true,
0245         'en_LC'       => true,
0246         'en_LR'       => true,
0247         'en_LS'       => true,
0248         'en_MG'       => true,
0249         'en_MH'       => true,
0250         'en_MO'       => true,
0251         'en_MP'       => true,
0252         'en_MS'       => true,
0253         'en_MT'       => true,
0254         'en_MU'       => true,
0255         'en_MW'       => true,
0256         'en_NA'       => true,
0257         'en_NF'       => true,
0258         'en_NG'       => true,
0259         'en_NR'       => true,
0260         'en_NU'       => true,
0261         'en_NZ'       => true,
0262         'en_PG'       => true,
0263         'en_PH'       => true,
0264         'en_PK'       => true,
0265         'en_PN'       => true,
0266         'en_PR'       => true,
0267         'en_PW'       => true,
0268         'en_RW'       => true,
0269         'en_SB'       => true,
0270         'en_SC'       => true,
0271         'en_SD'       => true,
0272         'en_SG'       => true,
0273         'en_SH'       => true,
0274         'en_SL'       => true,
0275         'en_SS'       => true,
0276         'en_SX'       => true,
0277         'en_SZ'       => true,
0278         'en_TC'       => true,
0279         'en_TK'       => true,
0280         'en_TO'       => true,
0281         'en_TT'       => true,
0282         'en_TV'       => true,
0283         'en_TZ'       => true,
0284         'en_UG'       => true,
0285         'en_UM'       => true,
0286         'en_US'       => true,
0287         'en_US_POSIX' => true,
0288         'en_VC'       => true,
0289         'en_VG'       => true,
0290         'en_VI'       => true,
0291         'en_VU'       => true,
0292         'en_WS'       => true,
0293         'en_ZA'       => true,
0294         'en_ZM'       => true,
0295         'en_ZW'       => true,
0296         'eo'          => true,
0297         'eo_001'      => true,
0298         'es'          => true,
0299         'es_419'      => true,
0300         'es_AR'       => true,
0301         'es_BO'       => true,
0302         'es_CL'       => true,
0303         'es_CO'       => true,
0304         'es_CR'       => true,
0305         'es_CU'       => true,
0306         'es_DO'       => true,
0307         'es_EA'       => true,
0308         'es_EC'       => true,
0309         'es_ES'       => true,
0310         'es_GQ'       => true,
0311         'es_GT'       => true,
0312         'es_HN'       => true,
0313         'es_IC'       => true,
0314         'es_MX'       => true,
0315         'es_NI'       => true,
0316         'es_PA'       => true,
0317         'es_PE'       => true,
0318         'es_PH'       => true,
0319         'es_PR'       => true,
0320         'es_PY'       => true,
0321         'es_SV'       => true,
0322         'es_US'       => true,
0323         'es_UY'       => true,
0324         'es_VE'       => true,
0325         'et'          => true,
0326         'et_EE'       => true,
0327         'eu'          => true,
0328         'eu_ES'       => true,
0329         'ewo'         => true,
0330         'ewo_CM'      => true,
0331         'fa'          => true,
0332         'fa_AF'       => true,
0333         'fa_IR'       => true,
0334         'ff'          => true,
0335         'ff_CM'       => true,
0336         'ff_GN'       => true,
0337         'ff_MR'       => true,
0338         'fr_PM'       => true,
0339         'ff_SN'       => true,
0340         'fr_WF'       => true,
0341         'fi'          => true,
0342         'fi_FI'       => true,
0343         'fil'         => true,
0344         'fil_PH'      => true,
0345         'fo'          => true,
0346         'fo_FO'       => true,
0347         'fr'          => true,
0348         'fr_BE'       => true,
0349         'fr_BF'       => true,
0350         'fr_BI'       => true,
0351         'fr_BJ'       => true,
0352         'fr_BL'       => true,
0353         'fr_CA'       => true,
0354         'fr_CD'       => true,
0355         'fr_CF'       => true,
0356         'fr_CG'       => true,
0357         'fr_CH'       => true,
0358         'fr_CI'       => true,
0359         'fr_CM'       => true,
0360         'fr_DJ'       => true,
0361         'fr_DZ'       => true,
0362         'fr_FR'       => true,
0363         'fr_GA'       => true,
0364         'fr_GF'       => true,
0365         'fr_GN'       => true,
0366         'fr_GP'       => true,
0367         'fr_GQ'       => true,
0368         'fr_HT'       => true,
0369         'fr_KM'       => true,
0370         'fr_LU'       => true,
0371         'fr_MA'       => true,
0372         'fr_MC'       => true,
0373         'fr_MF'       => true,
0374         'fr_MG'       => true,
0375         'fr_ML'       => true,
0376         'fr_MQ'       => true,
0377         'fr_MR'       => true,
0378         'fr_MU'       => true,
0379         'fr_NC'       => true,
0380         'fr_NE'       => true,
0381         'fr_PF'       => true,
0382         'fr_RE'       => true,
0383         'fr_RW'       => true,
0384         'fr_SC'       => true,
0385         'fr_SN'       => true,
0386         'fr_SY'       => true,
0387         'fr_TD'       => true,
0388         'fr_TG'       => true,
0389         'fr_TN'       => true,
0390         'fr_VU'       => true,
0391         'fr_YT'       => true,
0392         'fur'         => true,
0393         'fur_IT'      => true,
0394         'fy'          => true,
0395         'fy_NL'       => true,
0396         'ga'          => true,
0397         'ga_IE'       => true,
0398         'gd'          => true,
0399         'gd_GB'       => true,
0400         'gl'          => true,
0401         'gl_ES'       => true,
0402         'gsw'         => true,
0403         'gsw_CH'      => true,
0404         'gsw_LI'      => true,
0405         'gu'          => true,
0406         'gu_IN'       => true,
0407         'guz'         => true,
0408         'guz_KE'      => true,
0409         'gv'          => true,
0410         'gv_IM'       => true,
0411         'ha'          => true,
0412         'ha_Latn'     => true,
0413         'ha_Latn_GH'  => true,
0414         'ha_Latn_NE'  => true,
0415         'ha_Latn_NG'  => true,
0416         'haw'         => true,
0417         'haw_US'      => true,
0418         'he'          => true,
0419         'he_IL'       => true,
0420         'hi'          => true,
0421         'hi_IN'       => true,
0422         'hr'          => true,
0423         'hr_BA'       => true,
0424         'hr_HR'       => true,
0425         'hu'          => true,
0426         'hu_HU'       => true,
0427         'hy'          => true,
0428         'hy_AM'       => true,
0429         'ia'          => true,
0430         'ia_FR'       => true,
0431         'id'          => true,
0432         'id_ID'       => true,
0433         'ig'          => true,
0434         'ig_NG'       => true,
0435         'ii'          => true,
0436         'ii_CN'       => true,
0437         'is'          => true,
0438         'is_IS'       => true,
0439         'it'          => true,
0440         'it_CH'       => true,
0441         'it_IT'       => true,
0442         'it_SM'       => true,
0443         'ja'          => true,
0444         'ja_JP'       => true,
0445         'jgo'         => true,
0446         'jgo_CM'      => true,
0447         'jmc'         => true,
0448         'jmc_TZ'      => true,
0449         'ka'          => true,
0450         'ka_GE'       => true,
0451         'kab'         => true,
0452         'kab_DZ'      => true,
0453         'kam'         => true,
0454         'kam_KE'      => true,
0455         'kde'         => true,
0456         'kde_TZ'      => true,
0457         'kea'         => true,
0458         'kea_CV'      => true,
0459         'khq'         => true,
0460         'khq_ML'      => true,
0461         'ki'          => true,
0462         'ki_KE'       => true,
0463         'kk'          => true,
0464         'kk_Cyrl'     => true,
0465         'kk_Cyrl_KZ'  => true,
0466         'kkj'         => true,
0467         'kkj_CM'      => true,
0468         'kl'          => true,
0469         'kl_GL'       => true,
0470         'kln'         => true,
0471         'kln_KE'      => true,
0472         'km'          => true,
0473         'km_KH'       => true,
0474         'kn'          => true,
0475         'kn_IN'       => true,
0476         'ko'          => true,
0477         'ko_KP'       => true,
0478         'ko_KR'       => true,
0479         'kok'         => true,
0480         'kok_IN'      => true,
0481         'ks'          => true,
0482         'ks_Arab'     => true,
0483         'ks_Arab_IN'  => true,
0484         'ksb'         => true,
0485         'ksb_TZ'      => true,
0486         'ksf'         => true,
0487         'ksf_CM'      => true,
0488         'ksh'         => true,
0489         'ksh_DE'      => true,
0490         'kw'          => true,
0491         'kw_GB'       => true,
0492         'ky'          => true,
0493         'ky_Cyrl'     => true,
0494         'ky_Cyrl_KG'  => true,
0495         'lag'         => true,
0496         'lag_TZ'      => true,
0497         'lg'          => true,
0498         'lg_UG'       => true,
0499         'lkt'         => true,
0500         'lkt_US'      => true,
0501         'ln'          => true,
0502         'ln_AO'       => true,
0503         'ln_CD'       => true,
0504         'ln_CF'       => true,
0505         'ln_CG'       => true,
0506         'lo'          => true,
0507         'lo_LA'       => true,
0508         'lt'          => true,
0509         'lt_LT'       => true,
0510         'lu'          => true,
0511         'lu_CD'       => true,
0512         'luo'         => true,
0513         'luo_KE'      => true,
0514         'luy'         => true,
0515         'luy_KE'      => true,
0516         'lv'          => true,
0517         'lv_LV'       => true,
0518         'mas'         => true,
0519         'mas_KE'      => true,
0520         'mas_TZ'      => true,
0521         'mer'         => true,
0522         'mer_KE'      => true,
0523         'mfe'         => true,
0524         'mfe_MU'      => true,
0525         'mg'          => true,
0526         'mg_MG'       => true,
0527         'mgh'         => true,
0528         'mgh_MZ'      => true,
0529         'mgo'         => true,
0530         'mgo_CM'      => true,
0531         'mk'          => true,
0532         'mk_MK'       => true,
0533         'ml'          => true,
0534         'ml_IN'       => true,
0535         'mn'          => true,
0536         'mn_Cyrl'     => true,
0537         'mn_Cyrl_MN'  => true,
0538         'mr'          => true,
0539         'mr_IN'       => true,
0540         'ms'          => true,
0541         'ms_Latn'     => true,
0542         'ms_Latn_BN'  => true,
0543         'ms_Latn_MY'  => true,
0544         'ms_Latn_SG'  => true,
0545         'mt'          => true,
0546         'mt_MT'       => true,
0547         'mua'         => true,
0548         'mua_CM'      => true,
0549         'my'          => true,
0550         'my_MM'       => true,
0551         'naq'         => true,
0552         'naq_NA'      => true,
0553         'nb'          => true,
0554         'nb_NO'       => true,
0555         'nb_SJ'       => true,
0556         'nd'          => true,
0557         'nd_ZW'       => true,
0558         'ne'          => true,
0559         'ne_IN'       => true,
0560         'ne_NP'       => true,
0561         'nl'          => true,
0562         'nl_AW'       => true,
0563         'nl_BE'       => true,
0564         'nl_BQ'       => true,
0565         'nl_CW'       => true,
0566         'nl_NL'       => true,
0567         'nl_SR'       => true,
0568         'nl_SX'       => true,
0569         'nmg'         => true,
0570         'nmg_CM'      => true,
0571         'nn'          => true,
0572         'nn_NO'       => true,
0573         'nnh'         => true,
0574         'nnh_CM'      => true,
0575         'nr'          => true,
0576         'nr_ZA'       => true,
0577         'nso'         => true,
0578         'nso_ZA'      => true,
0579         'nus'         => true,
0580         'nus_SD'      => true,
0581         'nyn'         => true,
0582         'nyn_UG'      => true,
0583         'om'          => true,
0584         'om_ET'       => true,
0585         'om_KE'       => true,
0586         'or'          => true,
0587         'or_IN'       => true,
0588         'ordinals'    => true,
0589         'os'          => true,
0590         'os_GE'       => true,
0591         'os_RU'       => true,
0592         'pa'          => true,
0593         'pa_Arab'     => true,
0594         'pa_Arab_PK'  => true,
0595         'pa_Guru'     => true,
0596         'pa_Guru_IN'  => true,
0597         'pl'          => true,
0598         'pl_PL'       => true,
0599         'plurals'     => true,
0600         'ps'          => true,
0601         'ps_AF'       => true,
0602         'pt'          => true,
0603         'pt_AO'       => true,
0604         'pt_BR'       => true,
0605         'pt_CV'       => true,
0606         'pt_GW'       => true,
0607         'pt_MO'       => true,
0608         'pt_MZ'       => true,
0609         'pt_PT'       => true,
0610         'pt_ST'       => true,
0611         'pt_TL'       => true,
0612         'rm'          => true,
0613         'rm_CH'       => true,
0614         'rn'          => true,
0615         'rn_BI'       => true,
0616         'ro'          => true,
0617         'ro_MD'       => true,
0618         'ro_RO'       => true,
0619         'rof'         => true,
0620         'rof_TZ'      => true,
0621         'ru'          => true,
0622         'ru_BY'       => true,
0623         'ru_KG'       => true,
0624         'ru_KZ'       => true,
0625         'ru_MD'       => true,
0626         'ru_RU'       => true,
0627         'ru_UA'       => true,
0628         'rw'          => true,
0629         'rw_RW'       => true,
0630         'rwk'         => true,
0631         'rwk_TZ'      => true,
0632         'sah'         => true,
0633         'sah_RU'      => true,
0634         'saq'         => true,
0635         'saq_KE'      => true,
0636         'sbp'         => true,
0637         'sbp_TZ'      => true,
0638         'se'          => true,
0639         'se_FI'       => true,
0640         'se_NO'       => true,
0641         'seh'         => true,
0642         'seh_MZ'      => true,
0643         'ses'         => true,
0644         'ses_ML'      => true,
0645         'sg'          => true,
0646         'sg_CF'       => true,
0647         'shi'         => true,
0648         'shi_Latn'    => true,
0649         'shi_Latn_MA' => true,
0650         'shi_Tfng'    => true,
0651         'shi_Tfng_MA' => true,
0652         'si'          => true,
0653         'si_LK'       => true,
0654         'sk'          => true,
0655         'sk_SK'       => true,
0656         'sl'          => true,
0657         'sl_SI'       => true,
0658         'sn'          => true,
0659         'sn_ZW'       => true,
0660         'so'          => true,
0661         'so_DJ'       => true,
0662         'so_ET'       => true,
0663         'so_KE'       => true,
0664         'so_SO'       => true,
0665         'sq'          => true,
0666         'sq_AL'       => true,
0667         'sq_MK'       => true,
0668         'sq_XK'       => true,
0669         'sr'          => true,
0670         'sr_Cyrl'     => true,
0671         'sr_Cyrl_BA'  => true,
0672         'sr_Cyrl_ME'  => true,
0673         'sr_Cyrl_RS'  => true,
0674         'sr_Cyrl_XK'  => true,
0675         'sr_Latn'     => true,
0676         'sr_Latn_BA'  => true,
0677         'sr_Latn_ME'  => true,
0678         'sr_Latn_RS'  => true,
0679         'sr_Latn_XK'  => true,
0680         'ss'          => true,
0681         'ss_SZ'       => true,
0682         'ss_ZA'       => true,
0683         'ssy'         => true,
0684         'ssy_ER'      => true,
0685         'st'          => true,
0686         'st_LS'       => true,
0687         'st_ZA'       => true,
0688         'sv'          => true,
0689         'sv_AX'       => true,
0690         'sv_FI'       => true,
0691         'sv_SE'       => true,
0692         'sw'          => true,
0693         'sw_KE'       => true,
0694         'sw_TZ'       => true,
0695         'sw_UG'       => true,
0696         'swc'         => true,
0697         'swc_CD'      => true,
0698         'ta'          => true,
0699         'ta_IN'       => true,
0700         'ta_LK'       => true,
0701         'ta_MY'       => true,
0702         'ta_SG'       => true,
0703         'te'          => true,
0704         'te_IN'       => true,
0705         'teo'         => true,
0706         'teo_KE'      => true,
0707         'teo_UG'      => true,
0708         'tg'          => true,
0709         'tg_Cyrl'     => true,
0710         'tg_Cyrl_TJ'  => true,
0711         'th'          => true,
0712         'th_TH'       => true,
0713         'ti'          => true,
0714         'ti_ER'       => true,
0715         'ti_ET'       => true,
0716         'tig'         => true,
0717         'tig_ER'      => true,
0718         'tn'          => true,
0719         'tn_BW'       => true,
0720         'tn_ZA'       => true,
0721         'to'          => true,
0722         'to_TO'       => true,
0723         'tr'          => true,
0724         'tr_CY'       => true,
0725         'tr_TR'       => true,
0726         'ts'          => true,
0727         'ts_ZA'       => true,
0728         'twq'         => true,
0729         'twq_NE'      => true,
0730         'tzm'         => true,
0731         'tzm_Latn'    => true,
0732         'tzm_Latn_MA' => true,
0733         'ug'          => true,
0734         'ug_Arab'     => true,
0735         'ug_Arab_CN'  => true,
0736         'uk'          => true,
0737         'uk_UA'       => true,
0738         'ur'          => true,
0739         'ur_IN'       => true,
0740         'ur_PK'       => true,
0741         'uz'          => true,
0742         'uz_Arab'     => true,
0743         'uz_Arab_AF'  => true,
0744         'uz_Cyrl'     => true,
0745         'uz_Cyrl_UZ'  => true,
0746         'uz_Latn'     => true,
0747         'uz_Latn_UZ'  => true,
0748         'vai'         => true,
0749         'vai_Latn'    => true,
0750         'vai_Latn_LR' => true,
0751         'vai_Vaii'    => true,
0752         'vai_Vaii_LR' => true,
0753         've'          => true,
0754         've_ZA'       => true,
0755         'vi'          => true,
0756         'vi_VN'       => true,
0757         'vo'          => true,
0758         'vo_001'      => true,
0759         'vun'         => true,
0760         'vun_TZ'      => true,
0761         'wae'         => true,
0762         'wae_CH'      => true,
0763         'wal'         => true,
0764         'wal_ET'      => true,
0765         'xh'          => true,
0766         'xh_ZA'       => true,
0767         'xog'         => true,
0768         'xog_UG'      => true,
0769         'yav'         => true,
0770         'yav_CM'      => true,
0771         'yo'          => true,
0772         'yo_BJ'       => true,
0773         'yo_NG'       => true,
0774         'zgh'         => true,
0775         'zgh_MA'      => true,
0776         'zh'          => true,
0777         'zh_Hans'     => true,
0778         'zh_Hans_CN'  => true,
0779         'zh_Hans_HK'  => true,
0780         'zh_Hans_MO'  => true,
0781         'zh_Hans_SG'  => true,
0782         'zh_Hant'     => true,
0783         'zh_Hant_HK'  => true,
0784         'zh_Hant_MO'  => true,
0785         'zh_Hant_TW'  => true,
0786         'zu'          => true,
0787         'zu_ZA'       => true,
0788     );
0789 
0790     /**
0791      * Class wide Locale Constants
0792      *
0793      * @var array $_territoryData
0794      */
0795     private static $_territoryData = array(
0796         'AD' => 'ca_AD',
0797         'AE' => 'ar_AE',
0798         'AF' => 'fa_AF',
0799         'AG' => 'en_AG',
0800         'AI' => 'en_AI',
0801         'AL' => 'sq_AL',
0802         'AM' => 'hy_AM',
0803         'AN' => 'pap_AN',
0804         'AO' => 'pt_AO',
0805         'AQ' => 'und_AQ',
0806         'AR' => 'es_AR',
0807         'AS' => 'sm_AS',
0808         'AT' => 'de_AT',
0809         'AU' => 'en_AU',
0810         'AW' => 'nl_AW',
0811         'AX' => 'sv_AX',
0812         'AZ' => 'az_Latn_AZ',
0813         'BA' => 'bs_BA',
0814         'BB' => 'en_BB',
0815         'BD' => 'bn_BD',
0816         'BE' => 'nl_BE',
0817         'BF' => 'mos_BF',
0818         'BG' => 'bg_BG',
0819         'BH' => 'ar_BH',
0820         'BI' => 'rn_BI',
0821         'BJ' => 'fr_BJ',
0822         'BL' => 'fr_BL',
0823         'BM' => 'en_BM',
0824         'BN' => 'ms_BN',
0825         'BO' => 'es_BO',
0826         'BR' => 'pt_BR',
0827         'BS' => 'en_BS',
0828         'BT' => 'dz_BT',
0829         'BV' => 'und_BV',
0830         'BW' => 'en_BW',
0831         'BY' => 'be_BY',
0832         'BZ' => 'en_BZ',
0833         'CA' => 'en_CA',
0834         'CC' => 'ms_CC',
0835         'CD' => 'sw_CD',
0836         'CF' => 'fr_CF',
0837         'CG' => 'fr_CG',
0838         'CH' => 'de_CH',
0839         'CI' => 'fr_CI',
0840         'CK' => 'en_CK',
0841         'CL' => 'es_CL',
0842         'CM' => 'fr_CM',
0843         'CN' => 'zh_Hans_CN',
0844         'CO' => 'es_CO',
0845         'CR' => 'es_CR',
0846         'CU' => 'es_CU',
0847         'CV' => 'kea_CV',
0848         'CX' => 'en_CX',
0849         'CY' => 'el_CY',
0850         'CZ' => 'cs_CZ',
0851         'DE' => 'de_DE',
0852         'DJ' => 'aa_DJ',
0853         'DK' => 'da_DK',
0854         'DM' => 'en_DM',
0855         'DO' => 'es_DO',
0856         'DZ' => 'ar_DZ',
0857         'EC' => 'es_EC',
0858         'EE' => 'et_EE',
0859         'EG' => 'ar_EG',
0860         'EH' => 'ar_EH',
0861         'ER' => 'ti_ER',
0862         'ES' => 'es_ES',
0863         'ET' => 'en_ET',
0864         'FI' => 'fi_FI',
0865         'FJ' => 'hi_FJ',
0866         'FK' => 'en_FK',
0867         'FM' => 'chk_FM',
0868         'FO' => 'fo_FO',
0869         'FR' => 'fr_FR',
0870         'GA' => 'fr_GA',
0871         'GB' => 'en_GB',
0872         'GD' => 'en_GD',
0873         'GE' => 'ka_GE',
0874         'GF' => 'fr_GF',
0875         'GG' => 'en_GG',
0876         'GH' => 'ak_GH',
0877         'GI' => 'en_GI',
0878         'GL' => 'iu_GL',
0879         'GM' => 'en_GM',
0880         'GN' => 'fr_GN',
0881         'GP' => 'fr_GP',
0882         'GQ' => 'fan_GQ',
0883         'GR' => 'el_GR',
0884         'GS' => 'und_GS',
0885         'GT' => 'es_GT',
0886         'GU' => 'en_GU',
0887         'GW' => 'pt_GW',
0888         'GY' => 'en_GY',
0889         'HK' => 'zh_Hant_HK',
0890         'HM' => 'und_HM',
0891         'HN' => 'es_HN',
0892         'HR' => 'hr_HR',
0893         'HT' => 'ht_HT',
0894         'HU' => 'hu_HU',
0895         'ID' => 'id_ID',
0896         'IE' => 'en_IE',
0897         'IL' => 'he_IL',
0898         'IM' => 'en_IM',
0899         'IN' => 'hi_IN',
0900         'IO' => 'und_IO',
0901         'IQ' => 'ar_IQ',
0902         'IR' => 'fa_IR',
0903         'IS' => 'is_IS',
0904         'IT' => 'it_IT',
0905         'JE' => 'en_JE',
0906         'JM' => 'en_JM',
0907         'JO' => 'ar_JO',
0908         'JP' => 'ja_JP',
0909         'KE' => 'en_KE',
0910         'KG' => 'ky_Cyrl_KG',
0911         'KH' => 'km_KH',
0912         'KI' => 'en_KI',
0913         'KM' => 'ar_KM',
0914         'KN' => 'en_KN',
0915         'KP' => 'ko_KP',
0916         'KR' => 'ko_KR',
0917         'KW' => 'ar_KW',
0918         'KY' => 'en_KY',
0919         'KZ' => 'ru_KZ',
0920         'LA' => 'lo_LA',
0921         'LB' => 'ar_LB',
0922         'LC' => 'en_LC',
0923         'LI' => 'de_LI',
0924         'LK' => 'si_LK',
0925         'LR' => 'en_LR',
0926         'LS' => 'st_LS',
0927         'LT' => 'lt_LT',
0928         'LU' => 'fr_LU',
0929         'LV' => 'lv_LV',
0930         'LY' => 'ar_LY',
0931         'MA' => 'ar_MA',
0932         'MC' => 'fr_MC',
0933         'MD' => 'ro_MD',
0934         'ME' => 'sr_Latn_ME',
0935         'MF' => 'fr_MF',
0936         'MG' => 'mg_MG',
0937         'MH' => 'mh_MH',
0938         'MK' => 'mk_MK',
0939         'ML' => 'bm_ML',
0940         'MM' => 'my_MM',
0941         'MN' => 'mn_Cyrl_MN',
0942         'MO' => 'zh_Hant_MO',
0943         'MP' => 'en_MP',
0944         'MQ' => 'fr_MQ',
0945         'MR' => 'ar_MR',
0946         'MS' => 'en_MS',
0947         'MT' => 'mt_MT',
0948         'MU' => 'mfe_MU',
0949         'MV' => 'dv_MV',
0950         'MW' => 'ny_MW',
0951         'MX' => 'es_MX',
0952         'MY' => 'ms_MY',
0953         'MZ' => 'pt_MZ',
0954         'NA' => 'kj_NA',
0955         'NC' => 'fr_NC',
0956         'NE' => 'ha_Latn_NE',
0957         'NF' => 'en_NF',
0958         'NG' => 'en_NG',
0959         'NI' => 'es_NI',
0960         'NL' => 'nl_NL',
0961         'NO' => 'nb_NO',
0962         'NP' => 'ne_NP',
0963         'NR' => 'en_NR',
0964         'NU' => 'niu_NU',
0965         'NZ' => 'en_NZ',
0966         'OM' => 'ar_OM',
0967         'PA' => 'es_PA',
0968         'PE' => 'es_PE',
0969         'PF' => 'fr_PF',
0970         'PG' => 'tpi_PG',
0971         'PH' => 'fil_PH',
0972         'PK' => 'ur_PK',
0973         'PL' => 'pl_PL',
0974         'PM' => 'fr_PM',
0975         'PN' => 'en_PN',
0976         'PR' => 'es_PR',
0977         'PS' => 'ar_PS',
0978         'PT' => 'pt_PT',
0979         'PW' => 'pau_PW',
0980         'PY' => 'gn_PY',
0981         'QA' => 'ar_QA',
0982         'RE' => 'fr_RE',
0983         'RO' => 'ro_RO',
0984         'RS' => 'sr_Cyrl_RS',
0985         'RU' => 'ru_RU',
0986         'RW' => 'rw_RW',
0987         'SA' => 'ar_SA',
0988         'SB' => 'en_SB',
0989         'SC' => 'crs_SC',
0990         'SD' => 'ar_SD',
0991         'SE' => 'sv_SE',
0992         'SG' => 'en_SG',
0993         'SH' => 'en_SH',
0994         'SI' => 'sl_SI',
0995         'SJ' => 'nb_SJ',
0996         'SK' => 'sk_SK',
0997         'SL' => 'kri_SL',
0998         'SM' => 'it_SM',
0999         'SN' => 'fr_SN',
1000         'SO' => 'sw_SO',
1001         'SR' => 'srn_SR',
1002         'ST' => 'pt_ST',
1003         'SV' => 'es_SV',
1004         'SY' => 'ar_SY',
1005         'SZ' => 'en_SZ',
1006         'TC' => 'en_TC',
1007         'TD' => 'fr_TD',
1008         'TF' => 'und_TF',
1009         'TG' => 'fr_TG',
1010         'TH' => 'th_TH',
1011         'TJ' => 'tg_Cyrl_TJ',
1012         'TK' => 'tkl_TK',
1013         'TL' => 'pt_TL',
1014         'TM' => 'tk_TM',
1015         'TN' => 'ar_TN',
1016         'TO' => 'to_TO',
1017         'TR' => 'tr_TR',
1018         'TT' => 'en_TT',
1019         'TV' => 'tvl_TV',
1020         'TW' => 'zh_Hant_TW',
1021         'TZ' => 'sw_TZ',
1022         'UA' => 'uk_UA',
1023         'UG' => 'sw_UG',
1024         'UM' => 'en_UM',
1025         'US' => 'en_US',
1026         'UY' => 'es_UY',
1027         'UZ' => 'uz_Cyrl_UZ',
1028         'VA' => 'it_VA',
1029         'VC' => 'en_VC',
1030         'VE' => 'es_VE',
1031         'VG' => 'en_VG',
1032         'VI' => 'en_VI',
1033         'VN' => 'vi_VN',
1034         'VU' => 'bi_VU',
1035         'WF' => 'wls_WF',
1036         'WS' => 'sm_WS',
1037         'YE' => 'ar_YE',
1038         'YT' => 'swb_YT',
1039         'ZA' => 'en_ZA',
1040         'ZM' => 'en_ZM',
1041         'ZW' => 'sn_ZW'
1042     );
1043 
1044     /**
1045      * Autosearch constants
1046      */
1047     const BROWSER     = 'browser';
1048     const ENVIRONMENT = 'environment';
1049     const ZFDEFAULT   = 'default';
1050 
1051     /**
1052      * Defines if old behaviour should be supported
1053      * Old behaviour throws notices and will be deleted in future releases
1054      *
1055      * @var boolean
1056      */
1057     public static $compatibilityMode = false;
1058 
1059     /**
1060      * Internal variable
1061      *
1062      * @var boolean
1063      */
1064     private static $_breakChain = false;
1065 
1066     /**
1067      * Actual set locale
1068      *
1069      * @var string Locale
1070      */
1071     protected $_locale;
1072 
1073     /**
1074      * Automatic detected locale
1075      *
1076      * @var string Locales
1077      */
1078     protected static $_auto;
1079 
1080     /**
1081      * Browser detected locale
1082      *
1083      * @var string Locales
1084      */
1085     protected static $_browser;
1086 
1087     /**
1088      * Environment detected locale
1089      *
1090      * @var string Locales
1091      */
1092     protected static $_environment;
1093 
1094     /**
1095      * Default locale
1096      *
1097      * @var string Locales
1098      */
1099     protected static $_default = array('en' => true);
1100 
1101     /**
1102      * Generates a locale object
1103      * If no locale is given a automatic search is done
1104      * Then the most probable locale will be automatically set
1105      * Search order is
1106      *  1. Given Locale
1107      *  2. HTTP Client
1108      *  3. Server Environment
1109      *  4. Framework Standard
1110      *
1111      * @param  string|Zend_Locale $locale (Optional) Locale for parsing input
1112      * @throws Zend_Locale_Exception When autodetection has been failed
1113      */
1114     public function __construct($locale = null)
1115     {
1116         $this->setLocale($locale);
1117     }
1118 
1119     /**
1120      * Serialization Interface
1121      *
1122      * @return string
1123      */
1124     public function serialize()
1125     {
1126         return serialize($this);
1127     }
1128 
1129     /**
1130      * Returns a string representation of the object
1131      *
1132      * @return string
1133      */
1134     public function toString()
1135     {
1136         return (string) $this->_locale;
1137     }
1138 
1139     /**
1140      * Returns a string representation of the object
1141      * Alias for toString
1142      *
1143      * @return string
1144      */
1145     public function __toString()
1146     {
1147         return $this->toString();
1148     }
1149 
1150     /**
1151      * Return the default locale
1152      *
1153      * @return array Returns an array of all locale string
1154      */
1155     public static function getDefault()
1156     {
1157         if ((self::$compatibilityMode === true) or (func_num_args() > 0)) {
1158             if (!self::$_breakChain) {
1159                 self::$_breakChain = true;
1160                 trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
1161                 $params = func_get_args();
1162                 $param = null;
1163                 if (isset($params[0])) {
1164                     $param = $params[0];
1165                 }
1166                 return self::getOrder($param);
1167             }
1168 
1169             self::$_breakChain = false;
1170         }
1171 
1172         return self::$_default;
1173     }
1174 
1175     /**
1176      * Sets a new default locale which will be used when no locale can be detected
1177      * If provided you can set a quality between 0 and 1 (or 2 and 100)
1178      * which represents the percent of quality the browser
1179      * requested within HTTP
1180      *
1181      * @param  string|Zend_Locale $locale  Locale to set
1182      * @param  float              $quality The quality to set from 0 to 1
1183      * @throws Zend_Locale_Exception When a autolocale was given
1184      * @throws Zend_Locale_Exception When a unknown locale was given
1185      * @return void
1186      */
1187     public static function setDefault($locale, $quality = 1)
1188     {
1189         if (($locale === 'auto') or ($locale === 'root') or ($locale === 'default') or
1190             ($locale === 'environment') or ($locale === 'browser')) {
1191             // require_once 'Zend/Locale/Exception.php';
1192             throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
1193         }
1194 
1195         if (($quality < 0.1) or ($quality > 100)) {
1196             // require_once 'Zend/Locale/Exception.php';
1197             throw new Zend_Locale_Exception("Quality must be between 0.1 and 100");
1198         }
1199 
1200         if ($quality > 1) {
1201             $quality /= 100;
1202         }
1203 
1204         $locale = self::_prepareLocale($locale);
1205         if (isset(self::$_localeData[(string) $locale]) === true) {
1206             self::$_default = array((string) $locale => $quality);
1207         } else {
1208             $elocale = explode('_', (string) $locale);
1209             if (isset(self::$_localeData[$elocale[0]]) === true) {
1210                 self::$_default = array($elocale[0] => $quality);
1211             } else {
1212                 // require_once 'Zend/Locale/Exception.php';
1213                 throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
1214             }
1215         }
1216 
1217         self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
1218     }
1219 
1220     /**
1221      * Expects the Systems standard locale
1222      *
1223      * For Windows:
1224      * f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C
1225      * would be recognised as de_AT
1226      *
1227      * @return array
1228      */
1229     public static function getEnvironment()
1230     {
1231         if (self::$_environment !== null) {
1232             return self::$_environment;
1233         }
1234 
1235         // require_once 'Zend/Locale/Data/Translation.php';
1236 
1237         $language      = setlocale(LC_ALL, 0);
1238         $languages     = explode(';', $language);
1239         $languagearray = array();
1240 
1241         foreach ($languages as $locale) {
1242             if (strpos($locale, '=') !== false) {
1243                 $language = substr($locale, strpos($locale, '='));
1244                 $language = substr($language, 1);
1245             }
1246 
1247             if ($language !== 'C') {
1248                 if (strpos($language, '.') !== false) {
1249                     $language = substr($language, 0, strpos($language, '.'));
1250                 } else if (strpos($language, '@') !== false) {
1251                     $language = substr($language, 0, strpos($language, '@'));
1252                 }
1253 
1254                 $language = str_ireplace(
1255                     array_keys(Zend_Locale_Data_Translation::$languageTranslation),
1256                     array_values(Zend_Locale_Data_Translation::$languageTranslation),
1257                     (string) $language
1258                 );
1259 
1260                 $language = str_ireplace(
1261                     array_keys(Zend_Locale_Data_Translation::$regionTranslation),
1262                     array_values(Zend_Locale_Data_Translation::$regionTranslation),
1263                     $language
1264                 );
1265 
1266                 if (isset(self::$_localeData[$language]) === true) {
1267                     $languagearray[$language] = 1;
1268                     if (strpos($language, '_') !== false) {
1269                         $languagearray[substr($language, 0, strpos($language, '_'))] = 1;
1270                     }
1271                 }
1272             }
1273         }
1274 
1275         self::$_environment = $languagearray;
1276         return $languagearray;
1277     }
1278 
1279     /**
1280      * Return an array of all accepted languages of the client
1281      * Expects RFC compilant Header !!
1282      *
1283      * The notation can be :
1284      * de,en-UK-US;q=0.5,fr-FR;q=0.2
1285      *
1286      * @return array - list of accepted languages including quality
1287      */
1288     public static function getBrowser()
1289     {
1290         if (self::$_browser !== null) {
1291             return self::$_browser;
1292         }
1293 
1294         $httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
1295         if (empty($httplanguages) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
1296             $httplanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
1297         }
1298 
1299         $languages     = array();
1300         if (empty($httplanguages)) {
1301             return $languages;
1302         }
1303 
1304         $accepted = preg_split('/,\s*/', $httplanguages);
1305 
1306         foreach ($accepted as $accept) {
1307             $match  = null;
1308             $result = preg_match('/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
1309                                  $accept, $match);
1310 
1311             if ($result < 1) {
1312                 continue;
1313             }
1314 
1315             if (isset($match[2]) === true) {
1316                 $quality = (float) $match[2];
1317             } else {
1318                 $quality = 1.0;
1319             }
1320 
1321             $countrys = explode('-', $match[1]);
1322             $region   = array_shift($countrys);
1323 
1324             $country2 = explode('_', $region);
1325             $region   = array_shift($country2);
1326 
1327             foreach ($countrys as $country) {
1328                 $languages[$region . '_' . strtoupper($country)] = $quality;
1329             }
1330 
1331             foreach ($country2 as $country) {
1332                 $languages[$region . '_' . strtoupper($country)] = $quality;
1333             }
1334 
1335             if ((isset($languages[$region]) === false) || ($languages[$region] < $quality)) {
1336                 $languages[$region] = $quality;
1337             }
1338         }
1339 
1340         self::$_browser = $languages;
1341         return $languages;
1342     }
1343 
1344     /**
1345      * Sets a new locale
1346      *
1347      * @param  string|Zend_Locale $locale (Optional) New locale to set
1348      * @return void
1349      */
1350     public function setLocale($locale = null)
1351     {
1352         $locale = self::_prepareLocale($locale);
1353 
1354         if (isset(self::$_localeData[(string) $locale]) === false) {
1355             // Is it an alias? If so, we can use this locale
1356             if (isset(self::$_localeAliases[$locale]) === true) {
1357                 $this->_locale = $locale;
1358                 return;
1359             }
1360 
1361             $region = substr((string) $locale, 0, 3);
1362             if (isset($region[2]) === true) {
1363                 if (($region[2] === '_') or ($region[2] === '-')) {
1364                     $region = substr($region, 0, 2);
1365                 }
1366             }
1367 
1368             if (isset(self::$_localeData[(string) $region]) === true) {
1369                 $this->_locale = $region;
1370             } else {
1371                 $this->_locale = 'root';
1372             }
1373         } else {
1374             $this->_locale = $locale;
1375         }
1376     }
1377 
1378     /**
1379      * Returns the language part of the locale
1380      *
1381      * @return string
1382      */
1383     public function getLanguage()
1384     {
1385         $locale = explode('_', $this->_locale);
1386         return $locale[0];
1387     }
1388 
1389     /**
1390      * Returns the region part of the locale if available
1391      *
1392      * @return string|false - Regionstring
1393      */
1394     public function getRegion()
1395     {
1396         $locale = explode('_', $this->_locale);
1397         if (isset($locale[1]) === true) {
1398             return $locale[1];
1399         }
1400 
1401         return false;
1402     }
1403 
1404     /**
1405      * Return the accepted charset of the client
1406      *
1407      * @return string
1408      */
1409     public static function getHttpCharset()
1410     {
1411         $httpcharsets = getenv('HTTP_ACCEPT_CHARSET');
1412 
1413         $charsets = array();
1414         if ($httpcharsets === false) {
1415             return $charsets;
1416         }
1417 
1418         $accepted = preg_split('/,\s*/', $httpcharsets);
1419         foreach ($accepted as $accept) {
1420             if (empty($accept) === true) {
1421                 continue;
1422             }
1423 
1424             if (strpos($accept, ';') !== false) {
1425                 $quality        = (float) substr($accept, (strpos($accept, '=') + 1));
1426                 $pos            = substr($accept, 0, strpos($accept, ';'));
1427                 $charsets[$pos] = $quality;
1428             } else {
1429                 $quality           = 1.0;
1430                 $charsets[$accept] = $quality;
1431             }
1432         }
1433 
1434         return $charsets;
1435     }
1436 
1437     /**
1438      * Returns true if both locales are equal
1439      *
1440      * @param  Zend_Locale $object Locale to check for equality
1441      * @return boolean
1442      */
1443     public function equals(Zend_Locale $object)
1444     {
1445         if ($object->toString() === $this->toString()) {
1446             return true;
1447         }
1448 
1449         return false;
1450     }
1451 
1452     /**
1453      * Returns localized informations as array, supported are several
1454      * types of informations.
1455      * For detailed information about the types look into the documentation
1456      *
1457      * @param  string             $path   (Optional) Type of information to return
1458      * @param  string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
1459      * @param  string             $value  (Optional) Value for detail list
1460      * @return array Array with the wished information in the given language
1461      */
1462     public static function getTranslationList($path = null, $locale = null, $value = null)
1463     {
1464         // require_once 'Zend/Locale/Data.php';
1465         $locale = self::findLocale($locale);
1466         $result = Zend_Locale_Data::getList($locale, $path, $value);
1467         if (empty($result) === true) {
1468             return false;
1469         }
1470 
1471         return $result;
1472     }
1473 
1474     /**
1475      * Returns an array with the name of all languages translated to the given language
1476      *
1477      * @param  string|Zend_Locale $locale (Optional) Locale for language translation
1478      * @return array
1479      * @deprecated
1480      */
1481     public static function getLanguageTranslationList($locale = null)
1482     {
1483         trigger_error("The method getLanguageTranslationList is deprecated. Use getTranslationList('language', $locale) instead", E_USER_NOTICE);
1484         return self::getTranslationList('language', $locale);
1485     }
1486 
1487     /**
1488      * Returns an array with the name of all scripts translated to the given language
1489      *
1490      * @param  string|Zend_Locale $locale (Optional) Locale for script translation
1491      * @return array
1492      * @deprecated
1493      */
1494     public static function getScriptTranslationList($locale = null)
1495     {
1496         trigger_error("The method getScriptTranslationList is deprecated. Use getTranslationList('script', $locale) instead", E_USER_NOTICE);
1497         return self::getTranslationList('script', $locale);
1498     }
1499 
1500     /**
1501      * Returns an array with the name of all countries translated to the given language
1502      *
1503      * @param  string|Zend_Locale $locale (Optional) Locale for country translation
1504      * @return array
1505      * @deprecated
1506      */
1507     public static function getCountryTranslationList($locale = null)
1508     {
1509         trigger_error("The method getCountryTranslationList is deprecated. Use getTranslationList('territory', $locale, 2) instead", E_USER_NOTICE);
1510         return self::getTranslationList('territory', $locale, 2);
1511     }
1512 
1513     /**
1514      * Returns an array with the name of all territories translated to the given language
1515      * All territories contains other countries.
1516      *
1517      * @param  string|Zend_Locale $locale (Optional) Locale for territory translation
1518      * @return array
1519      * @deprecated
1520      */
1521     public static function getTerritoryTranslationList($locale = null)
1522     {
1523         trigger_error("The method getTerritoryTranslationList is deprecated. Use getTranslationList('territory', $locale, 1) instead", E_USER_NOTICE);
1524         return self::getTranslationList('territory', $locale, 1);
1525     }
1526 
1527     /**
1528      * Returns a localized information string, supported are several types of informations.
1529      * For detailed information about the types look into the documentation
1530      *
1531      * @param  string             $value  Name to get detailed information about
1532      * @param  string             $path   (Optional) Type of information to return
1533      * @param  string|Zend_Locale $locale (Optional) Locale|Language for which this informations should be returned
1534      * @return string|false The wished information in the given language
1535      */
1536     public static function getTranslation($value = null, $path = null, $locale = null)
1537     {
1538         // require_once 'Zend/Locale/Data.php';
1539         $locale = self::findLocale($locale);
1540         $result = Zend_Locale_Data::getContent($locale, $path, $value);
1541         if (empty($result) === true && '0' !== $result) {
1542             return false;
1543         }
1544 
1545         return $result;
1546     }
1547 
1548     /**
1549      * Returns the localized language name
1550      *
1551      * @param  string $value  Name to get detailed information about
1552      * @param  string $locale (Optional) Locale for language translation
1553      * @return array
1554      * @deprecated
1555      */
1556     public static function getLanguageTranslation($value, $locale = null)
1557     {
1558         trigger_error("The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead", E_USER_NOTICE);
1559         return self::getTranslation($value, 'language', $locale);
1560     }
1561 
1562     /**
1563      * Returns the localized script name
1564      *
1565      * @param  string $value  Name to get detailed information about
1566      * @param  string $locale (Optional) locale for script translation
1567      * @return array
1568      * @deprecated
1569      */
1570     public static function getScriptTranslation($value, $locale = null)
1571     {
1572         trigger_error("The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead", E_USER_NOTICE);
1573         return self::getTranslation($value, 'script', $locale);
1574     }
1575 
1576     /**
1577      * Returns the localized country name
1578      *
1579      * @param  string             $value  Name to get detailed information about
1580      * @param  string|Zend_Locale $locale (Optional) Locale for country translation
1581      * @return array
1582      * @deprecated
1583      */
1584     public static function getCountryTranslation($value, $locale = null)
1585     {
1586         trigger_error("The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead", E_USER_NOTICE);
1587         return self::getTranslation($value, 'country', $locale);
1588     }
1589 
1590     /**
1591      * Returns the localized territory name
1592      * All territories contains other countries.
1593      *
1594      * @param  string             $value  Name to get detailed information about
1595      * @param  string|Zend_Locale $locale (Optional) Locale for territory translation
1596      * @return array
1597      * @deprecated
1598      */
1599     public static function getTerritoryTranslation($value, $locale = null)
1600     {
1601         trigger_error("The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead", E_USER_NOTICE);
1602         return self::getTranslation($value, 'territory', $locale);
1603     }
1604 
1605     /**
1606      * Returns an array with translated yes strings
1607      *
1608      * @param  string|Zend_Locale $locale (Optional) Locale for language translation (defaults to $this locale)
1609      * @return array
1610      */
1611     public static function getQuestion($locale = null)
1612     {
1613         // require_once 'Zend/Locale/Data.php';
1614         $locale            = self::findLocale($locale);
1615         $quest             = Zend_Locale_Data::getList($locale, 'question');
1616         $yes               = explode(':', $quest['yes']);
1617         $no                = explode(':', $quest['no']);
1618         $quest['yes']      = $yes[0];
1619         $quest['yesarray'] = $yes;
1620         $quest['no']       = $no[0];
1621         $quest['noarray']  = $no;
1622         $quest['yesexpr']  = self::_prepareQuestionString($yes);
1623         $quest['noexpr']   = self::_prepareQuestionString($no);
1624 
1625         return $quest;
1626     }
1627 
1628     /**
1629      * Internal function for preparing the returned question regex string
1630      *
1631      * @param  string $input Regex to parse
1632      * @return string
1633      */
1634     private static function _prepareQuestionString($input)
1635     {
1636         $regex = '';
1637         if (is_array($input) === true) {
1638             $regex = '^';
1639             $start = true;
1640             foreach ($input as $row) {
1641                 if ($start === false) {
1642                     $regex .= '|';
1643                 }
1644 
1645                 $start  = false;
1646                 $regex .= '(';
1647                 $one    = null;
1648                 if (strlen($row) > 2) {
1649                     $one = true;
1650                 }
1651 
1652                 foreach (str_split($row, 1) as $char) {
1653                     $regex .= '[' . $char;
1654                     $regex .= strtoupper($char) . ']';
1655                     if ($one === true) {
1656                         $one    = false;
1657                         $regex .= '(';
1658                     }
1659                 }
1660 
1661                 if ($one === false) {
1662                     $regex .= ')';
1663                 }
1664 
1665                 $regex .= '?)';
1666             }
1667         }
1668 
1669         return $regex;
1670     }
1671 
1672     /**
1673      * Checks if a locale identifier is a real locale or not
1674      * Examples:
1675      * "en_XX" refers to "en", which returns true
1676      * "XX_yy" refers to "root", which returns false
1677      *
1678      * @param  string|Zend_Locale $locale     Locale to check for
1679      * @param  boolean            $strict     (Optional) If true, no rerouting will be done when checking
1680      * @param  boolean            $compatible (DEPRECATED) Only for internal usage, brakes compatibility mode
1681      * @return boolean If the locale is known dependend on the settings
1682      */
1683     public static function isLocale($locale, $strict = false, $compatible = true)
1684     {
1685         if (($locale instanceof Zend_Locale)
1686             || (is_string($locale) && array_key_exists($locale, self::$_localeData))
1687         ) {
1688             return true;
1689         }
1690 
1691         // Is it an alias?
1692         if (is_string($locale) && array_key_exists($locale, self::$_localeAliases)) {
1693             return true;
1694         }
1695 
1696         if (($locale === null) || (!is_string($locale) and !is_array($locale))) {
1697             return false;
1698         }
1699 
1700         try {
1701             $locale = self::_prepareLocale($locale, $strict);
1702         } catch (Zend_Locale_Exception $e) {
1703             return false;
1704         }
1705 
1706         if (($compatible === true) and (self::$compatibilityMode === true)) {
1707             trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
1708             if (isset(self::$_localeData[$locale]) === true) {
1709                 return $locale;
1710             } else if (!$strict) {
1711                 $locale = explode('_', $locale);
1712                 if (isset(self::$_localeData[$locale[0]]) === true) {
1713                     return $locale[0];
1714                 }
1715             }
1716         } else {
1717             if (isset(self::$_localeData[$locale]) === true) {
1718                 return true;
1719             } else if (!$strict) {
1720                 $locale = explode('_', $locale);
1721                 if (isset(self::$_localeData[$locale[0]]) === true) {
1722                     return true;
1723                 }
1724             }
1725         }
1726 
1727         return false;
1728     }
1729 
1730     /**
1731      * Finds the proper locale based on the input
1732      * Checks if it exists, degrades it when necessary
1733      * Detects registry locale and when all fails tries to detect a automatic locale
1734      * Returns the found locale as string
1735      *
1736      * @param string $locale
1737      * @throws Zend_Locale_Exception When the given locale is no locale or the autodetection fails
1738      * @return string
1739      */
1740     public static function findLocale($locale = null)
1741     {
1742         if ($locale === null) {
1743             // require_once 'Zend/Registry.php';
1744             if (Zend_Registry::isRegistered('Zend_Locale')) {
1745                 $locale = Zend_Registry::get('Zend_Locale');
1746             }
1747         }
1748 
1749         if ($locale === null) {
1750             $locale = new Zend_Locale();
1751         }
1752 
1753         if (!Zend_Locale::isLocale($locale, true, false)) {
1754             if (!Zend_Locale::isLocale($locale, false, false)) {
1755                 $locale = Zend_Locale::getLocaleToTerritory($locale);
1756 
1757                 if (empty($locale)) {
1758                     // require_once 'Zend/Locale/Exception.php';
1759                     throw new Zend_Locale_Exception("The locale '$locale' is no known locale");
1760                 }
1761             } else {
1762                 $locale = new Zend_Locale($locale);
1763             }
1764         }
1765 
1766         $locale = self::_prepareLocale($locale);
1767         return $locale;
1768     }
1769 
1770     /**
1771      * Returns the expected locale for a given territory
1772      *
1773      * @param string $territory Territory for which the locale is being searched
1774      * @return string|null Locale string or null when no locale has been found
1775      */
1776     public static function getLocaleToTerritory($territory)
1777     {
1778         $territory = strtoupper($territory);
1779         if (array_key_exists($territory, self::$_territoryData)) {
1780             return self::$_territoryData[$territory];
1781         }
1782 
1783         return null;
1784     }
1785 
1786     /**
1787      * Returns a list of all known locales where the locale is the key
1788      * Only real locales are returned, the internal locales 'root', 'auto', 'browser'
1789      * and 'environment' are suppressed
1790      *
1791      * @return array List of all Locales
1792      */
1793     public static function getLocaleList()
1794     {
1795         $list = self::$_localeData;
1796         unset($list['root']);
1797         unset($list['auto']);
1798         unset($list['browser']);
1799         unset($list['environment']);
1800         return $list;
1801     }
1802 
1803     /**
1804      * Returns the set cache
1805      *
1806      * @return Zend_Cache_Core The set cache
1807      */
1808     public static function getCache()
1809     {
1810         // require_once 'Zend/Locale/Data.php';
1811         return Zend_Locale_Data::getCache();
1812     }
1813 
1814     /**
1815      * Sets a cache
1816      *
1817      * @param  Zend_Cache_Core $cache Cache to set
1818      * @return void
1819      */
1820     public static function setCache(Zend_Cache_Core $cache)
1821     {
1822         // require_once 'Zend/Locale/Data.php';
1823         Zend_Locale_Data::setCache($cache);
1824     }
1825 
1826     /**
1827      * Returns true when a cache is set
1828      *
1829      * @return boolean
1830      */
1831     public static function hasCache()
1832     {
1833         // require_once 'Zend/Locale/Data.php';
1834         return Zend_Locale_Data::hasCache();
1835     }
1836 
1837     /**
1838      * Removes any set cache
1839      *
1840      * @return void
1841      */
1842     public static function removeCache()
1843     {
1844         // require_once 'Zend/Locale/Data.php';
1845         Zend_Locale_Data::removeCache();
1846     }
1847 
1848     /**
1849      * Clears all set cache data
1850      *
1851      * @param string $tag Tag to clear when the default tag name is not used
1852      * @return void
1853      */
1854     public static function clearCache($tag = null)
1855     {
1856         // require_once 'Zend/Locale/Data.php';
1857         Zend_Locale_Data::clearCache($tag);
1858     }
1859 
1860     /**
1861      * Disables the set cache
1862      *
1863      * @param  boolean $flag True disables any set cache, default is false
1864      * @return void
1865      */
1866     public static function disableCache($flag)
1867     {
1868         // require_once 'Zend/Locale/Data.php';
1869         Zend_Locale_Data::disableCache($flag);
1870     }
1871 
1872     /**
1873      * Internal function, returns a single locale on detection
1874      *
1875      * @param  string|Zend_Locale $locale (Optional) Locale to work on
1876      * @param  boolean            $strict (Optional) Strict preparation
1877      * @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended
1878      * @return string
1879      */
1880     private static function _prepareLocale($locale, $strict = false)
1881     {
1882         if ($locale instanceof Zend_Locale) {
1883             $locale = $locale->toString();
1884         }
1885 
1886         if (is_array($locale)) {
1887             return '';
1888         }
1889 
1890         if (empty(self::$_auto) === true) {
1891             self::$_browser     = self::getBrowser();
1892             self::$_environment = self::getEnvironment();
1893             self::$_breakChain  = true;
1894             self::$_auto        = self::getBrowser() + self::getEnvironment() + self::getDefault();
1895         }
1896 
1897         if (!$strict) {
1898             if ($locale === 'browser') {
1899                 $locale = self::$_browser;
1900             }
1901 
1902             if ($locale === 'environment') {
1903                 $locale = self::$_environment;
1904             }
1905 
1906             if ($locale === 'default') {
1907                 $locale = self::$_default;
1908             }
1909 
1910             if (($locale === 'auto') or ($locale === null)) {
1911                 $locale = self::$_auto;
1912             }
1913 
1914             if (is_array($locale) === true) {
1915                 $locale = key($locale);
1916             }
1917         }
1918 
1919         // This can only happen when someone extends Zend_Locale and erases the default
1920         if ($locale === null) {
1921             // require_once 'Zend/Locale/Exception.php';
1922             throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
1923         }
1924 
1925         if (strpos($locale, '-') !== false) {
1926             $locale = strtr($locale, '-', '_');
1927         }
1928 
1929         $parts = explode('_', $locale);
1930         if (!isset(self::$_localeData[$parts[0]])) {
1931             if ((count($parts) == 1) && array_key_exists($parts[0], self::$_territoryData)) {
1932                 return self::$_territoryData[$parts[0]];
1933             }
1934 
1935             return '';
1936         }
1937 
1938         foreach($parts as $key => $value) {
1939             if ((strlen($value) < 2) || (strlen($value) > 3)) {
1940                 unset($parts[$key]);
1941             }
1942         }
1943 
1944         $locale = implode('_', $parts);
1945         return (string) $locale;
1946     }
1947 
1948     /**
1949      * Search the locale automatically and return all used locales
1950      * ordered by quality
1951      *
1952      * Standard Searchorder is Browser, Environment, Default
1953      *
1954      * @param  string  $searchorder (Optional) Searchorder
1955      * @return array Returns an array of all detected locales
1956      */
1957     public static function getOrder($order = null)
1958     {
1959         switch ($order) {
1960             case self::ENVIRONMENT:
1961                 self::$_breakChain = true;
1962                 $languages         = self::getEnvironment() + self::getBrowser() + self::getDefault();
1963                 break;
1964 
1965             case self::ZFDEFAULT:
1966                 self::$_breakChain = true;
1967                 $languages         = self::getDefault() + self::getEnvironment() + self::getBrowser();
1968                 break;
1969 
1970             default:
1971                 self::$_breakChain = true;
1972                 $languages         = self::getBrowser() + self::getEnvironment() + self::getDefault();
1973                 break;
1974         }
1975 
1976         return $languages;
1977     }
1978 
1979     /**
1980      * Is the given locale in the list of aliases?
1981      *
1982      * @param  string|Zend_Locale $locale Locale to work on
1983      * @return boolean
1984      */
1985     public static function isAlias($locale)
1986     {
1987         if ($locale instanceof Zend_Locale) {
1988             $locale = $locale->toString();
1989         }
1990 
1991         return isset(self::$_localeAliases[$locale]);
1992     }
1993 
1994     /**
1995      * Return an alias' actual locale.
1996      *
1997      * @param  string|Zend_Locale $locale Locale to work on
1998      * @return string
1999      */
2000     public static function getAlias($locale)
2001     {
2002         if ($locale instanceof Zend_Locale) {
2003             $locale = $locale->toString();
2004         }
2005 
2006         if (isset(self::$_localeAliases[$locale]) === true) {
2007             return self::$_localeAliases[$locale];
2008         }
2009 
2010         return (string) $locale;
2011     }
2012 }