Localization
Not compatible with the Maps SDK v10
This plugin is not compatible with the Maps SDK v10 or higher. The Maps SDK v10 and higher comes with localization functionality built in. See the Localization documentation.
The Localization Plugin for Android is an excellent option for adjusting your Android project's map experience according to the individual user's preferences. The plugin:
- Automatically detects the set language on the Android device and changes map text to that language. The plugin can change map text based on the Android device's language preference, but it also provides methods to programmatically change the text to a language independent of what the user set their device's language to. For example, if a user sets their phone to French but, they meet a Spanish-only speaking person, your app could provide a way for the French speaker to switch the map to Spanish temporarily. The map can then be switched back to French once their interaction is over.
- Adjusts the map camera to an area of the world that is associated with the device's set language. For example, say that the user set their device to German. The plugin can detect this so that when the map begins, the map camera's target is focused on Germany.
Install the Localization Plugin
To start developing an application using the Localization Plugin, you'll need to add the appropriate dependencies inside of your build.gradle
. The Localization Plugin dependency includes the Mapbox Maps SDK for Android. You can find all dependencies given below on MavenCentral.
Android's 64K method count limit
If your application is over the 64K method limit, you can shrink, obfuscate, and optimize your code with R8 or ProGuard. If those steps do not lower your method count below 64K, you can also enable multidex.
Add the dependency
- Start Android Studio.
- Open up your application's
build.gradle
. - Make sure that your project's
minSdkVersion
is API 14 or higher. - Under dependencies, add a new build rule for the latest
mapbox-android-plugin-localization-v9
. - Click the Sync Project with Gradle Files near the toolbar in Studio.
repositories {
mavenCentral()
}
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0'
}