Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

locale - List of available collators in PHP?

I am considering using collators in PHP (I am no expert in PHP). Is there a way to know/list all collators available in PHP? I am looking for something similar to Java's Collator.getAvailableLocales(). Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think the Collator is using the locale information from the CLDR repository.

I compiled a list from it's current trunk (at the time of writing: 2020-02-23):

af          af_NA       af_ZA       ar          ar_001      ar_AE       
ar_BH       ar_DZ       ar_EG       ar_IQ       ar_JO       ar_KW       
ar_LB       ar_LY       ar_MA       ar_OM       ar_QA       ar_SA       
ar_SD       ar_SY       ar_TN       ar_YE       as          as_IN       
az          az_Latn     az_Latn_AZ  be          be_BY       bg          
bg_BG       bn          bn_BD       bn_IN       bs          bs_BA       
ca          ca_ES       chr         chr_US      cs          cs_CZ       
cy          cy_GB       da          da_DK       de          de_AT       
de_BE       de_CH       de_DE       de_LI       de_LU       dz          
ee          ee_GH       ee_TG       el          el_CY       el_GR       
en          en_AS       en_AU       en_BB       en_BE       en_BM       
en_BW       en_BZ       en_CA       en_GB       en_GU       en_HK       
en_IE       en_IN       en_JM       en_MH       en_MP       en_MT       
en_MU       en_NA       en_NZ       en_PH       en_PK       en_SG       
en_TT       en_UM       en_US       en_US_POSIX en_VI       en_ZA       
en_ZW       eo          es          es_419      es_AR       es_BO       
es_CL       es_CO       es_CR       es_DO       es_EC       es_ES       
es_GQ       es_GT       es_HN       es_MX       es_NI       es_PA       
es_PE       es_PR       es_PY       es_SV       es_US       es_UY       
es_VE       et          et_EE       fa          fa_AF       fa_IR       
fi          fi_FI       fil         fil_PH      fo          fo_FO       
fr          fr_BE       fr_BF       fr_BI       fr_BJ       fr_BL       
fr_CA       fr_CD       fr_CF       fr_CG       fr_CH       fr_CI       
fr_CM       fr_DJ       fr_FR       fr_GA       fr_GN       fr_GP       
fr_GQ       fr_KM       fr_LU       fr_MC       fr_MF       fr_MG       
fr_ML       fr_MQ       fr_NE       fr_RE       fr_RW       fr_SN       
fr_TD       fr_TG       ga          ga_IE       gu          gu_IN       
ha          ha_Latn     ha_Latn_GH  ha_Latn_NE  ha_Latn_NG  haw         
haw_US      he          he_IL       hi          hi_IN       hr          
hr_HR       hu          hu_HU       hy          hy_AM       id          
id_ID       ig          ig_NG       is          is_IS       it          
it_CH       it_IT       ja          ja_JP       ka          ka_GE       
kk          kk_KZ       kl          kl_GL       km          km_KH       
kn          kn_IN       ko          ko_KR       kok         kok_IN      
ky          ky_KG       ln          ln_CD       ln_CG       lt          
lt_LT       lv          lv_LV       mk          mk_MK       ml          
ml_IN       mr          mr_IN       ms          ms_BN       ms_MY       
mt          mt_MT       my          my_MM       nb          nb_NO       
nl          nl_AW       nl_BE       nl_CW       nl_NL       nl_SX       
nn          nn_NO       nso         nso_ZA      om          om_ET       
om_KE       or          or_IN       pa          pa_Arab     pa_Arab_PK  
pa_Guru     pa_Guru_IN  pl          pl_PL       ps          ps_AF       
pt          pt_AO       pt_BR       pt_GW       pt_MZ       pt_PT       
pt_ST       ro          ro_MD       ro_RO       ru          ru_MD       
ru_RU       ru_UA       se          se_FI       se_NO       si          
si_LK       sk          sk_SK       sl          sl_SI       sq          
sq_AL       sr          sr_Cyrl     sr_Cyrl_BA  sr_Cyrl_ME  sr_Cyrl_RS  
sr_Latn     sr_Latn_BA  sr_Latn_ME  sr_Latn_RS  st          st_LS       
st_ZA       sv          sv_FI       sv_SE       sw          sw_KE       
sw_TZ       ta          ta_IN       ta_LK       te          te_IN       
th          th_TH       tn          tn_ZA       to          to_TO       
tr          tr_TR       uk          uk_UA       ur          ur_IN       
ur_PK       vi          vi_VN       wae         wae_CH      xh          
xh_ZA       yo          yo_NG       zh          zh_Hans     zh_Hans_CN  
zh_Hans_SG  zh_Hant     zh_Hant_HK  zh_Hant_MO  zh_Hant_TW  zu          
zu_ZA       

Or grouped:

af (af_NA, af_ZA)
ar (ar_001, ar_AE, ar_BH, ar_DZ, ar_EG, ar_IQ, ar_JO, ar_KW, ar_LB, ar_LY, ar_MA, ar_OM, ar_QA, ar_SA, ar_SD, ar_SY, ar_TN, ar_YE)
as (as_IN)
az (az_Latn, az_Latn_AZ)
be (be_BY)
bg (bg_BG)
bn (bn_BD, bn_IN)
bs (bs_BA)
ca (ca_ES)
cs (cs_CZ)
cy (cy_GB)
da (da_DK)
de (de_AT, de_BE, de_CH, de_DE, de_LI, de_LU)
dz
ee (ee_GH, ee_TG)
el (el_CY, el_GR)
en (en_AS, en_AU, en_BB, en_BE, en_BM, en_BW, en_BZ, en_CA, en_GB, en_GU, en_HK, en_IE, en_IN, en_JM, en_MH, en_MP, en_MT, en_MU, en_NA, en_NZ, en_PH, en_PK, en_SG, en_TT, en_UM, en_VI, en_ZA, en_ZW)
en_US
en_US_POSIX
eo
es (es_419, es_AR, es_BO, es_CL, es_CO, es_CR, es_DO, es_EC, es_ES, es_GQ, es_GT, es_HN, es_MX, es_NI, es_PA, es_PE, es_PR, es_PY, es_SV, es_US, es_UY, es_VE)
et (et_EE)
fa (fa_IR)
fa_AF
fi (fi_FI)
fil (fil_PH)
fo (fo_FO)
fr (fr_BE, fr_BF, fr_BI, fr_BJ, fr_BL, fr_CD, fr_CF, fr_CG, fr_CH, fr_CI, fr_CM, fr_DJ, fr_FR, fr_GA, fr_GN, fr_GP, fr_GQ, fr_KM, fr_LU, fr_MC, fr_MF, fr_MG, fr_ML, fr_MQ, fr_NE, fr_RE, fr_RW, fr_SN, fr_TD, fr_TG)
fr_CA
gu (gu_IN)
ha (ha_Latn, ha_Latn_GH, ha_Latn_NE, ha_Latn_NG)
haw (haw_US)
he (he_IL)
hi (hi_IN)
hr (hr_HR)
hu (hu_HU)
hy (hy_AM)
ig (ig_NG)
is (is_IS)
ja (ja_JP)
kk (kk_KZ)
kl (kl_GL)
km (km_KH)
kn (kn_IN)
ko (ko_KR)
kok (kok_IN)
ln (ln_CD, ln_CG)
lt (lt_LT)
lv (lv_LV)
mk (mk_MK)
ml (ml_IN)
mr (mr_IN)
mt (mt_MT)
my (my_MM)
nb (nb_NO)
nn (nn_NO)
nso (nso_ZA)
om (om_ET, om_KE)
or (or_IN)
pa (pa_Arab, pa_Arab_PK, pa_Guru, pa_Guru_IN)
pl (pl_PL)
ps (ps_AF)
ro (ro_RO, ro_MD)
root (chr, chr_US, ga, ga_IE, id, id_ID, it, it_CH, it_IT, ka, ka_GE, ky, ky_KG, ms, ms_BN, ms_MY, nl, nl_AW, nl_BE, nl_CW, nl_NL, nl_SX, pt, pt_AO, pt_BR, pt_GW, pt_MZ, pt_PT, pt_ST, st, st_LS, st_ZA, sw, sw_KE, sw_TZ, xh, xh_ZA, zu, zu_ZA)
ru (ru_MD, ru_RU, ru_UA)
se (se_FI, se_NO)
si (si_LK)
sk (sk_SK)
sl (sl_SI)
sq (sq_AL)
sr (sr_Cyrl, sr_Cyrl_BA, sr_Cyrl_ME, sr_Cyrl_RS)
sr_Latn (sr_Latn_RS, sr_Latn_BA, sr_Latn_ME)
sv (sv_FI, sv_SE)
ta (ta_IN, ta_LK)
te (te_IN)
th (th_TH)
tn (tn_ZA)
to (to_TO)
tr (tr_TR)
uk (uk_UA)
ur (ur_PK, ur_IN)
vi (vi_VN)
wae (wae_CH)
yo (yo_NG)
zh (zh_Hans, zh_Hans_CN, zh_Hans_SG)
zh_Hant (zh_Hant_HK, zh_Hant_MO, zh_Hant_TW)

You can see the base locale in the filename, e.g. de.xml, when you go inside the file, you fined an element like this one:

<collations validSubLocales="de_AT de_BE de_CH de_DE de_LI de_LU">

which lists additional Sublocales. Script and Territory is available in the file as well.

It takes some time until the CLDR data comes into Intl (C) which then is bind against PHP Intl extension. So cross check with the Intl library version / binding on your system. Just in case it differs a bit from your installation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...