Style.localizeLabels(into:forLayerIds:) is unable to localize the map’s labels into Simplified Chinese or, one of the locales supported by Mapbox Streets source v8. Attempting to localize the labels into Simplified Chinese results in a symbol layer that is either unlocalized or completely blank. This issue also affects Hong Kong Traditional Chinese.
Diagnosis
As of #480, Style.getLocaleValue(locale:) hard-codes the locale codes supported by Mapbox Streets source v8:
|
let supportedLocaleIdentifiers = ["ar", "de", "en", "es", "fr", "it", "ja", "ko", "pt", "ru", "vi", "zh", "zh-Hans", "zh-Hant", "zh-Hant-TW"] |
However, it matches the passed-in Locale’s bare language code against that list:
|
// Do nothing if we do not support the locale |
|
if !supportedLocaleIdentifiers.contains(locale.languageCode!) { |
|
return nil |
|
} |
A phone may be set to a Locale with the identifier zh-Hant-HK, meaning Hong Kong Traditional Chinese. But this Locale’s language code is just zh, so despite zh-Hant being supported by the Streets source, the method ends up localizing into zh, which is just Chinese. The special logic to map zh-Hant-TW to zh-Hant does not apply to zh-Hant-HK.
Another common identifier is zh-Hans-CN, which also falls through the cracks and gets mapped to just zh.
convertExpressionForLocalization(symbolLayer:localeValue:) ends up replacing each name_en get expression with a name_zh get expression. But the Streets source no longer supports the generic zh locale as of v8; instead, only name_zh-Hans and name_zh-Hant fields are provided. Depending on the style’s fallback rules, the label will either appear in the local language rather than Chinese, or it will be blank.
Suggestion
supportedLocaleIdentifiers should be a list of locale codes that appear in the names of name_* fields in the Streets source – nothing less, nothing more.
When matching against this array, check both Locale.languageCode and Locale.regionCode.
/cc @mapbox/maps-ios @mapbox/navigation-ios
Style.localizeLabels(into:forLayerIds:)is unable to localize the map’s labels into Simplified Chinese or, one of the locales supported by Mapbox Streets source v8. Attempting to localize the labels into Simplified Chinese results in a symbol layer that is either unlocalized or completely blank. This issue also affects Hong Kong Traditional Chinese.Diagnosis
As of #480,
Style.getLocaleValue(locale:)hard-codes the locale codes supported by Mapbox Streets source v8:mapbox-maps-ios/Sources/MapboxMaps/Style/Style+Localization.swift
Line 38 in 34ea7ad
However, it matches the passed-in Locale’s bare language code against that list:
mapbox-maps-ios/Sources/MapboxMaps/Style/Style+Localization.swift
Lines 40 to 43 in 34ea7ad
A phone may be set to a Locale with the identifier
zh-Hant-HK, meaning Hong Kong Traditional Chinese. But this Locale’s language code is justzh, so despitezh-Hantbeing supported by the Streets source, the method ends up localizing intozh, which is just Chinese. The special logic to mapzh-Hant-TWtozh-Hantdoes not apply tozh-Hant-HK.Another common identifier is
zh-Hans-CN, which also falls through the cracks and gets mapped to justzh.convertExpressionForLocalization(symbolLayer:localeValue:)ends up replacing eachname_enget expression with aname_zhget expression. But the Streets source no longer supports the genericzhlocale as of v8; instead, onlyname_zh-Hansandname_zh-Hantfields are provided. Depending on the style’s fallback rules, the label will either appear in the local language rather than Chinese, or it will be blank.Suggestion
supportedLocaleIdentifiersshould be a list of locale codes that appear in the names ofname_*fields in the Streets source – nothing less, nothing more.When matching against this array, check both
Locale.languageCodeandLocale.regionCode./cc @mapbox/maps-ios @mapbox/navigation-ios