Search code examples
internationalizationglobalizationicu

List of language names translated into corresponding language


For my software project, I'm looking for a list of language display names per locale as they are written in the corresponding language, like "Português" in pt_BR or "日本語" in jp_JP.


Solution

  • You can find such data and much more in CLDR (Common Locale Data Repository) or using ICU libraries in your software which utilize the data from CLDR. Here is an excerpts from the data for Portuguese regarding name of languages:

    ...
    <language type="ps">pashto</language>
    <language type="ps" alt="variant" draft="contributed">pushto</language>
    <language type="pt">português</language>
    <language type="pt_BR">português do Brasil</language>
    <language type="pt_PT">português europeu</language>
    <language type="qu">quíchua</language>
    ...
    

    Also, you can check the demo pages to see the availability of the information through ICU. Getting the name of a specific language according to a specific locale setting using ICU is simple. Here, I'm quoting this answer:

    #include <unicode/locid.h>
    #include <unicode/ustream.h>
    #include <iostream>
    
    int main()
    {
      Locale l("pt_BR");
      UnicodeString result;
      std::cout <<   l.getDisplayName(l, result) << std::endl;
    }