mapbox-maps-android
mapbox-maps-android copied to clipboard
Localization default language support bug
Environment
- Android OS version: All versions
- Devices affected: All devices
- Maps SDK Version: 10.8.0
Observed behavior and steps to reproduce
The localization extension already has a default language support feature but it's not possible to switch the map language to the local language because it returns from the isSupportedLanguage() condition.
Precondition:
- Let's assume the user's default language is Turkish
Steps to reproduce:
- Create an extension like this
fun MapView.localizeMap(locale: Locale, style: String = Style.MAPBOX_STREETS) {
getMapboxMap().loadStyleUri(style) {
it.localizeLabels(locale)
}
}
- Call mapView.localizeMap(Locale.ENGLISH) this will change the map language to English
- Call mapView.localizeMap(Locale.getDefault()) this will not change the map language to Turkish because it's not in the supported language list.
Suggested solution 1: Localization.kt:22
internal fun setMapLanguage(locale: Locale?, style: StyleInterface, layerIds: List<String>?) {
var convertedLocale = if (locale == null) "name" else "name_${locale.language}"
if (!isSupportedLanguage(convertedLocale)) {
logE(TAG, "Locale: $locale is not supported.")
return
}
StyleInterfaceExtension.kt:12
@JvmOverloads
fun StyleInterface.localizeLabels(locale: Locale?, layerIds: List<String>? = null) {
setMapLanguage(locale, this, layerIds)
}
Expected behavior
If language is not in the supported language list, the local language feature can be used.