language-list icon indicating copy to clipboard operation
language-list copied to clipboard

request: include native list

Open dicktyr opened this issue 5 years ago • 3 comments

a "native" list with each language in its native language and script would be useful

e.g.

ru русский
sa संस्कृतम्
en English

dicktyr avatar Mar 07 '20 17:03 dicktyr

Any reason my message from yesterday got removed?

fabswt avatar Nov 20 '20 11:11 fabswt

I came up with this:

/**
 * Let's get the language code + English name + Endonym (the language's name in
 * the language) for ALL locales supported by PHP.
 */
$languages = ResourceBundle::getLocales('');

header("Content-Type: text/plain");
echo "CODE\tLANGUAGE_NAME\tENDONYM\n";

foreach($languages as $language) {
    echo
      $language
      . "\t"
      . ucfirst(Locale::getDisplayName($language, 'en-US'))
      . "\t"
      . mb_convert_case(
        Locale::getDisplayName($language, $language),
        MB_CASE_TITLE,
        'UTF-8'
      )
      . "\n";
}

It will return:

CODE	LANGUAGE_NAME	ENDONYM
af	Afrikaans	Afrikaans
af_NA	Afrikaans (Namibia)	Afrikaans (Namibië)
af_ZA	Afrikaans (South Africa)	Afrikaans (Suid-Afrika)
agq	Aghem	Aghem
agq_CM	Aghem (Cameroon)	Aghem (Kàmàlûŋ)
ak	Akan	Akan
ak_GH	Akan (Ghana)	Akan (Gaana)
am	Amharic	አማርኛ
am_ET	Amharic (Ethiopia)	አማርኛ (ኢትዮጵያ)
ar	Arabic	العربية
ar_001	Arabic (World)	العربية (العالم)
ar_AE	Arabic (United Arab Emirates)	العربية (الإمارات العربية المتحدة)
...

fabswt avatar Nov 23 '20 09:11 fabswt

thank you for the work around :}

dicktyr avatar Nov 23 '20 17:11 dicktyr