Reputation: 309
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.
Upvotes: 1
Views: 213
Reputation: 3276
What platform are you on? If you are on Win32, you want GetLocaleInfoEx
with LOCALE_SNATIVELANGUAGENAME
. If you are on .Net, you want the NativeName
property on a System.Globalization.CultureInfo
object. If you are using WinRT, you want the NativeName
property on a Windows.Globalization.Language
object.
Upvotes: 1
Reputation: 1965
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;
}
Upvotes: 3