Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change language settings (locale) for the device

Tags:

I know it's possible to have multiple languages in a single application through the res/string and depending on Locale. Here is a case (ANDROID) controling the user language

Now how can I change the language in the phone ? Like I'd do by Menu > Settings > Language & Keyboard > Select locale > languages

Is there some real code to access to these settings ? Or should I create intent for a shortcut to the language settings. Please post some code

Edit : With Locale class developer.android.com/intl/fr/reference/java/util/Locale.html

The constructor is at least Locale(String language) The input is language. How can you retrieve the current language used on the device ?

like image 819
Raymond Chenon Avatar asked Apr 07 '10 22:04

Raymond Chenon


People also ask

How do I change my device locale?

To make the change persistent, you'll also have to confirm the locale change in the Language preferences screen. You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”.

What is device locale?

java.util.Locale. A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.

How do I find the locale of my device?

Key-Takeaway #5: To get the list of preferred locales of the device (as defined in the Settings), call Resources. getSystem(). getConfiguration(). getLocales() .

How can I add locale language in Android?

In this step, we are required to create a string resource file for the Hindi language. Go to app > res > values > right-click > New > Value Resource File and name it as strings. Now, we have to choose qualifiers as Locale from the available list and select the language as Hindi from the drop-down list.


2 Answers

Not sure about setting it directly from the app, but if you want to send the user there to change it themselves, try this:

Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName("com.android.settings", "com.android.settings.LanguageSettings");             startActivity(intent); 
like image 166
Jim Blackler Avatar answered Oct 19 '22 16:10

Jim Blackler


There is another way to open system settings to change the language:

Intent i = new Intent( android.provider.Settings.ACTION_LOCALE_SETTINGS ); startActivity( i ); 

It shows just the list of languages, and when you choose one - it changes the language on the device.

like image 34
Sergey Avatar answered Oct 19 '22 16:10

Sergey