How to change language Google Map V2 android
You can change location for Google Maps that use the Google Map API V2 by using a Locale Object. The language needs to be supported on the device being used though.
Here is the full list of supported languages.
With this code below I was able to change the language on the map to Chinese:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languageToLoad = "zh_CN";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
Result, language set to Chinese in the code (no manual changes) on a U.S. based phone:
I was also able to get it to show Korean, use this Locale code:
String languageToLoad = "ko_KR";
Result:
NOTE
It looks like the supported languages for Google Maps are listed here: https://developers.google.com/maps/faq#languagesupport
We only need to change the location in the application to get the Map´s descriptions with different language. We have to add validations to avoid the use of deprecated methods:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String language= "hi"; //Hindi language!.
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
if(Build.VERSION.SDK_INT>Build.VERSION_CODES.JELLY_BEAN){
config.setLocale(locale);
getContext().createConfigurationContext(config);
}else { //deprecated
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
}
...
...
...
Very important to say that all the languages are not supported, this is an example in Russian language:
We can get the code languages from:
https://www.transifex.com/explore/languages/
Just change the locale on the device. If translations are available, they will be shown automatically.
A screenshot of my US phone with the locale switched to Korean: