How to change language Google Map V2 android
Asked Answered
E

6

15

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.

Eustazio answered 4/4, 2014 at 12:48 Comment(3)
did you got solution for Hindi language? below given examples are working for "ko" but not for "hi".Bisexual
@ArthTilva This was very old query so I have forgotten about Hindi support.Eustazio
For people asking about the Hindi (hi_IN) language, check answer in: #48863017Schellens
M
13

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

Millsaps answered 26/5, 2015 at 7:5 Comment(9)
This code is very close to what I had already. This makes all the rest of my app use the desired locale, but not the map. Maybe it's because I use the Support library's map: getSupportFragmentManager().findFragmentById(R.id.map)Kratz
Well, it seems it works partially! Locale.setDefault(locale); seems to be the key, however it is heavily cached, so when I change the locale in the app, then it doesn't change the locale of the map.Kratz
@Kratz Interesting. One thing to note, be sure to call it before the call to setContentView(), or any other type of layout inflating.Millsaps
Hi, i'm not able to show google map in hindi language. i've updated play service and google map as well. any idea how can i get it done.Trophozoite
@VaishaliSharma Did you try the above solution using hi_IN?Millsaps
this doesn't change the map language until restart the app. is there any way to clear the cache ?Calends
@RameshKumar Not sure exactly why it wouldn't work in some cases. It looks like Hindi is supported if you look at the list: developers.google.com/maps/faq#languagesupport Be sure that the device you're testing on also supports the language.Millsaps
yes, my device is supported hindi language.but not show map in hindiIndenture
@DanielNugent Apologies for piling on this really old thread, but I tried the solution you have provided in this answer while using the locale "ko_KR" and it works correctly. However changing the locale to "hi" or "hi_IN" does not work. There exists an issue in google's issue tracker here to which I have added a comment.Enounce
E
3

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/

Electoral answered 5/9, 2017 at 21:28 Comment(0)
Y
1

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:

Yablon answered 5/4, 2014 at 9:15 Comment(8)
Does this work? I tried changing the device's locale to Italian, Spanish, French, but Google Maps is always shown in English.Jessabell
Yes, I tested it before I answered. I changed the locale on my phone to Korean, and my own Maps test app mostly changed to Korean, even the names of minor streets in my city. I used this app to change locale: play.google.com/store/apps/details?id=com.bruce.setlocaleYablon
Note: The app chooses its language when it starts. You may have to force stop the app and restart it to get it to change languages.Yablon
@GiulioPiancastelli i am having the same experience as you. Did you find a solution?Replace
@Replace I haven't tried the application suggested by Kevin. I would expect the map locale to change without using third party applications to help it. As things currently stand, I have yet to find a solution, sorry.Jessabell
The purpose of the third-party app I mentioned is to change the locale of the device, not the map specifically. Once the locale is changed, all apps that have resources for that locale should automatically start using them. (With the caveat that they must be restarted, which may mean force closing them.)Yablon
Is there a way to change the map's language programmatically from my app (without changing the system locale)?Kratz
@Kratz It's a little late! But I just posted an answer that changes the map language programmatically if you're still interested.Millsaps
A
1

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

Aliment answered 8/6, 2021 at 20:42 Comment(0)
L
0

With new Google Map Render Support now you will get this, Need to follow a few steps,

  1. Update Google Map Dependency

    implementation 'com.google.android.gms:play-services-maps:18.1.0'

  2. Create New Class that Extends the Application, and initialize a new Map Renderer.

     class MyApplication : Application() {
            override fun onCreate() {
            super.onCreate()
            MapsInitializer.initialize(
                applicationContext,
                MapsInitializer.Renderer.LATEST,
                object : OnMapsSdkInitializedCallback {
                override fun onMapsSdkInitialized(p0: MapsInitializer.Renderer) {
                     Log.e("MapsInitializer", p0.name)
                 }
             })
     }
    

    }

  3. Register MyApplication class in Manifest.

<application
    android:name="com.extra.MyApplication"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme">

enter image description here

Lettuce answered 12/4, 2023 at 5:6 Comment(0)
S
0

If you think that locale configuration is already correct as mentioned below and you still have the problem.

Locale locale = new Locale("en"); // Exmaple for English
Locale.setDefault(locale);
Resources resources = getResources();
Configuration configuration = resources.getConfiguration();
configuration.setLocale(locale);
resources.updateConfiguration(configuration, resources.getDisplayMetrics());

It is possible that you are using default google maps initializer which uses LEGACY renderer as below:

MapsInitializer.initialize(this);

If you really use it then let test with LATEST renderer instead:

MapsInitializer.initialize(this, MapsInitializer.Renderer.LATEST, null);

I tried and tested with many things, but it works with only with LATEST renderer.

Seiden answered 6/2, 2024 at 10:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.