Style.localizeLabels(into:forLayerIds:) should have a way to explicitly unlocalize a layer’s labels – that is, make it show names in the local language instead of a specific passed-in language. This was supported in Mapbox Maps SDK v6.x but has regressed as of #480.
Rationale
It should be possible to easily undo what Style.localizeLabels(into:forLayerIds:) does when passing in a specific locale.
It should also be possible to ensure that a layer matches the local language, in the event that the original style hard-coded a particular language. For example, the Mapbox Navigation Day/Night v1 styles hard-code English in its road labels, falling back to the local language. This is suboptimal for the Mapbox Navigation SDK, which is marketed around the world, so it would be beneficial to force the local language name instead of English.
Design considerations
In v6.x and the proof-of-concept port in mapbox/mapbox-navigation-ios#2933, -[NSExpression mgl_expressionLocalizedIntoLocale:] supports two special Locale values, both documented:
nil automatically selects the first language listed in the system Preferred Content Languages list (+[NSLocale preferredLanguages]) that is also supported by the Streets source.
- A Locale with the identifier
mul (the standard ISO 639-2 code for multilingual text) selects the name field, which is typically in the local language.
Unfortunately, neither of these options are available in v10. The locale argument is non-optional, though it isn’t a big deal to pass in the first value in NSLocale.preferredLanguages manually. More problematic is that passing in mul currently crashes, because it isn’t one of the hard-coded locale codes supported by Streets:
|
guard let localeValue = getLocaleValue(locale: locale) else { |
|
fatalError("This locale is not supported") |
|
} |
/cc @mapbox/maps-ios @mapbox/navigation-ios
Style.localizeLabels(into:forLayerIds:)should have a way to explicitly unlocalize a layer’s labels – that is, make it show names in the local language instead of a specific passed-in language. This was supported in Mapbox Maps SDK v6.x but has regressed as of #480.Rationale
It should be possible to easily undo what
Style.localizeLabels(into:forLayerIds:)does when passing in a specific locale.It should also be possible to ensure that a layer matches the local language, in the event that the original style hard-coded a particular language. For example, the Mapbox Navigation Day/Night v1 styles hard-code English in its road labels, falling back to the local language. This is suboptimal for the Mapbox Navigation SDK, which is marketed around the world, so it would be beneficial to force the local language name instead of English.
Design considerations
In v6.x and the proof-of-concept port in mapbox/mapbox-navigation-ios#2933,
-[NSExpression mgl_expressionLocalizedIntoLocale:]supports two special Locale values, both documented:nilautomatically selects the first language listed in the system Preferred Content Languages list (+[NSLocale preferredLanguages]) that is also supported by the Streets source.mul(the standard ISO 639-2 code for multilingual text) selects thenamefield, which is typically in the local language.Unfortunately, neither of these options are available in v10. The
localeargument is non-optional, though it isn’t a big deal to pass in the first value inNSLocale.preferredLanguagesmanually. More problematic is that passing inmulcurrently crashes, because it isn’t one of the hard-coded locale codes supported by Streets:mapbox-maps-ios/Sources/MapboxMaps/Style/Style+Localization.swift
Lines 10 to 12 in 34ea7ad
/cc @mapbox/maps-ios @mapbox/navigation-ios