Vishal Pawar
Vishal Pawar

Reputation: 4340

How to get System Language?

In application supporting multiple languages using Locale.setDefault(newLocale); we are changing the language but there is no way to change language to device default language. What is the best way to find device default language in settings programatically.

Upvotes: 3

Views: 4949

Answers (3)

John S.
John S.

Reputation: 646

Here's what you're looking for

Locale.getDefault().getLanguage();

Upvotes: 0

Alexander Pogrebnyak
Alexander Pogrebnyak

Reputation: 45576

In general, store user modifiable setting in a variable controlled by you, not Oracle. I.e. never call Locale.setDefault when user changes your application's locale, but rather change a variable under your control.

There are overrides for each locale-dependent method that take Locale parameter.

That's where you should pass locale variable under your control.

This way, you can always consult Locale.getDefault for system settings.

Upvotes: 2

Vyacheslav
Vyacheslav

Reputation: 27211

check this:

Resources.getSystem().getConfiguration().locale.getLanguage();

Upvotes: 5

Related Questions