I try to change the language of my application to Spanish, but I cannot find it.
Configuration c = new Configuration(getResources().getConfiguration()); c.locale = Locale.SPANISH; // does not exists
But this works:
c.locale = Locale.ENGLISH;
Could somebody help me?
Thanks!
A locale can be composed of both a base language, the country (territory) of use, and possibly codeset (which is usually assumed). For example, German is de, an abbreviation for Deutsch, while Swiss German is de_CH, CH being an abbreviation for Confederation Helvetica.
Using an Application (don't forget to define it in your manifest) we get the default locale when the app starts (onCreate()) and we update it when the user changes the language in the Android settings (onConfigurationChanged(Configuration)). That's all there is.
The construct Locale.US is equivalent to: new Locale("en", "US"); This particular Locale constructor requires two arguments: The language code and the country code for the Locale that you want to create.
Locale codes are derived from a classification system originally developed by NCES in the 1980s to describe a school's location ranging from “large city” to “rural.” The codes are based on the physical location represented by an address that is matched against a geographic database maintained by the Census Bureau.
Did you try Locale spanish = new Locale("es", "ES");
(see Localization Android)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With