0

For example if I need to get the Arabic language in Russian I will get:

арабский

Following this post:

Get language name in that language from language code

Locale will give the specific format for each language but will not give me for example how Spanish people say Russian or Arabic language. So this is not exactly what I need.

So the question: How can I get the Arabic or any other language name in different languages? Is there any built-in API to get these in Android or should I map them myself?

Emil Adz
  • 40,709
  • 36
  • 140
  • 187

1 Answers1

3

The API will give you what you want, but you need to use 2 separate Locale objects: one for the language who's name you want to display, and the other for the language you want to display that name in.

So, to display the name of Arabic language in Russian, you will need the following code:

Locale locToDisplay = Locale.forLanguageTag("ar");
Locale locToPrintIn = Locale.forLanguageTag("ru");

String nameToDisplay = locToDisplay.getDisplayLanguage(locToPrintIn);
Lev M.
  • 6,088
  • 1
  • 10
  • 23