Open 1ec5 opened 4 years ago
As a workaround, if you know the language you want to display and know that your custom tileset supports it, you can set the MGLSymbolStyleLayer.text
property directly without using this method:
// Objective-C
// Latin
labels.text = [NSExpression expressionWithFormat:@"name_la"];
// Latin, falling back to Ancient Greek or the native local name
labels.text = [NSExpression expressionWithFormat:@"mgl_coalesce({name_la, name_grc, name})"];
// Swift
// Latin
labels.text = NSExpression(withFormat: "name_la")
// Latin, falling back to Ancient Greek or the native local name
labels.text = NSExpression(withFormat: "mgl_coalesce({name_la, name_grc, name})")
-[NSExpression mgl_expressionLocalizedIntoLocale:]
only considers the passed-in locale if it’s one of the locales with a dedicatedname_*
property in the Mapbox Streets source. This check can get outdated: if a minor update to the Streets source adds a new language, users of that language don’t automatically see that language until we update a list on the client-side, as in #173. What’s more, if the application is pulling in a tileset other than the Streets source that follows thename_*
convention, it would be nice if this method would work without forcing the application to muck with expressions directly.The fix is to fashion another
name_*
key path expression based on thelocale
argument – without limiting it to the Streets languages – and inserting it at the front of this coalescing expression:https://github.com/mapbox/mapbox-gl-native-ios/blob/a13921663715be33907a9c1bdb8e220a43e03a83/platform/darwin/src/NSExpression%2BMGLAdditions.mm#L1567-L1571 https://github.com/mapbox/mapbox-gl-native-ios/blob/a13921663715be33907a9c1bdb8e220a43e03a83/platform/darwin/src/NSExpression%2BMGLAdditions.mm#L1590
/cc @mapbox/maps-ios