'How can I get the English spelling of the current default language regardless of the phone language?

I need to be able to compare language names between the phone's default language and a a language name that a third party gives me in English.

So if a phone is in Spanish then "español".equals("spanish") will fail. So even though the phone is in Spanish, I need the comparison to be "spanish".equals("spanish"). Hope that makes sense.

I have found a way to do it but I don't like setting the default Locale.

Locale def  = Locale.getDefault();
Locale english = Locale.ENGLISH;
Locale.setDefault(english);

Now def has Spanish as the DisplayLanguage.

But then I would have to set the default back after I do my comparison. And what happens if at that same time something else queries the locale?

Anyway, is there a better way to do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source