简体   繁体   中英

A list of "language_LOCALE" as well as accepted languages by country?

I'm looking for a list of countries with their main language(s) as well as Accept-Languages ones.

For instance:

{
  "south africa": {
    country_code: za,
    lang: en_ZA,
    accept_languages: [en_ZA, zu_ZA, af_ZA]
  },
  "....."
}

Is there any list like this which I could copy?

Or from what source could I compile it?

accept_languages comes from the browser, and in some browsers I am allowed to input a custom locale, whatever I want. So I can put any syntactically valid locale. For example ja-Cyrl-ZA (Japanese in South Africa written in Cyrillic script).

Some other browsers only give you a limited list to choose from. Some don't even allow you to specify a region, only a language. Some give you a very short list of countries.

So there are differences between browsers.

If what you really want is a list of languages used in a country, independent of Accept-Languages , this might be a good source of info in a machine readable format: https://github.com/unicode-org/cldr/blob/main/common/supplemental/supplementalData.xml

See the <territoryInfo> section. For example the info about South Africa is a line 4365 :

<territory type="ZA" gdp="767200000000" literacyPercent="93" population="56463600"> <!--South Africa-->
    <languagePopulation type="en" literacyPercent="99" populationPercent="31" officialStatus="official" references="R1265"/> <!--English-->
    <languagePopulation type="zu" literacyPercent="50" populationPercent="24" officialStatus="official_regional"/> <!--Zulu-->
    <languagePopulation type="xh" literacyPercent="50" populationPercent="18" officialStatus="official_regional"/> <!--Xhosa-->
    <languagePopulation type="af" literacyPercent="99" populationPercent="13" officialStatus="official_regional"/> <!--Afrikaans-->
    <languagePopulation type="nso" literacyPercent="50" populationPercent="9.4" officialStatus="official_regional"/> <!--Northern Sotho-->
    <languagePopulation type="tn" literacyPercent="50" populationPercent="8.2" officialStatus="official_regional"/> <!--Tswana-->
    <languagePopulation type="st" literacyPercent="50" populationPercent="7.9" officialStatus="official_regional"/> <!--Southern Sotho-->
    <languagePopulation type="ts" literacyPercent="50" populationPercent="4.4" officialStatus="official_regional"/> <!--Tsonga-->
    <languagePopulation type="ss" literacyPercent="50" populationPercent="2.7" officialStatus="official_regional"/> <!--Swati-->
    <languagePopulation type="ve" literacyPercent="50" populationPercent="2.3" officialStatus="official_regional"/> <!--Venda-->
    <languagePopulation type="hi" literacyPercent="69" populationPercent="2"/> <!--Hindi-->
    <languagePopulation type="nr" literacyPercent="50" populationPercent="1.6" officialStatus="official_regional"/> <!--South Ndebele-->
    <languagePopulation type="sw" literacyPercent="50" populationPercent="0.0018"/> <!--Swahili-->
</territory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM