Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change language Google Map V2 android

I am using google-play-service-lib. How can I change language of google map i.e. show locations in korian language or Hindi Language.

like image 910
Vibhor Bhardwaj Avatar asked Apr 04 '14 12:04

Vibhor Bhardwaj


People also ask

Why is my Google Maps suddenly in a different language?

Google Maps on the web: Click the menu in the top left, then click Language and select any language to set it. Google Maps app for Android: Tap your profile picture in the top right, tap Settings > Navigation settings > Voice selection > a language. To also adjust the text language go to Settings > App language.

Can you change Google Maps Voice Android?

In the Google Maps app, tap your avatar to the right of the search bar at the top of the app. Scroll down and select Settings. Scroll down and go to Navigation settings. Choose Voice selection.

How do I change Google Maps to Arabic?

Open the Google Maps app, on your Android phone or tablet, Now tap on your profile picture or initial Account Circle and then Settings. Then tap on Navigation settings and then on Voice. Choose a voice and language.


4 Answers

hope this easy solution for changing map language helps someone:

simply add call setUpMapLocale() in your activity onCreate():

 private fun setUpMapLocale() {
        val languageToLoad = "iw_IL" // your desired language locale
        val locale = Locale(languageToLoad)
        Locale.setDefault(locale)
        baseContext.resources.configuration.setLocale(locale)
    }

so i just had to call setLocale() on the existing configuration attached to baseContext resources

like image 114
Yarin Shitrit Avatar answered Oct 22 '22 18:10

Yarin Shitrit


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:

Chinese Map

I was also able to get it to show Korean, use this Locale code:

 String languageToLoad = "ko_KR";

Result:

Korean Map

NOTE

It looks like the supported languages for Google Maps are listed here: https://developers.google.com/maps/faq#languagesupport

like image 13
Daniel Nugent Avatar answered Oct 22 '22 19:10

Daniel Nugent


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:

introducir la descripción de la imagen aquí

We can get the code languages from:

https://www.transifex.com/explore/languages/

like image 3
Jorgesys Avatar answered Oct 22 '22 17:10

Jorgesys


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:

like image 1
Kevin Krumwiede Avatar answered Oct 22 '22 19:10

Kevin Krumwiede