-
Notifications
You must be signed in to change notification settings - Fork 1.3k
No localized low-zoom labels when system language is Simplified Chinese #12164
Comments
@lloydsheng do you have time to investigate this? cc @chriswu42 |
@lilykaiser Happy to help investigate this issue. cc @suntony |
@1ec5 I checked the tile data, These layers did have no
My initial thought was that can we add the
@julianrex @1ec5 Glad to hear your thougts about this. |
Unfortunately, GL doesn’t currently support adding fields to vector tiles at runtime. (This is a concept sometimes called “data join”.) Better to alias one field with another in the expressions instead.
The navigation SDK has similar logic that determines the locale to pass into The special case would have to live in
The fallback could be implemented by wrapping key path expressions in NSExpression(format: "mgl_coalesce({name_zh-Hans, name_zh})") into: NSExpression(format: """
mgl_coalesce({
mgl_coalesce({name_zh-Hans, name_zh}),
mgl_coalesce({name_zh-Hans, name_zh})
})
""") With a different locale the second time, it would become: NSExpression(format: """
mgl_coalesce({
name_en,
name_en
})
""") If we could positively identify a coalescing expression as the result of an existing localization operation, then we might be able to replace the expression instead of more deeply nesting it, somewhere around here: mapbox-gl-native/platform/darwin/src/NSExpression+MGLAdditions.mm Lines 1519 to 1530 in 192c611
|
@1ec5 Thanks for your feedback 👍. I've pushed some changes to fix this issue #12387. I think it also made the SDK compatible with name fields of Mapbox Streets v8. /cc @chriswu42 @suntony |
We could append a dummy key path expression to the end of the coalescing array, something like
If it does, then we can replace the expression with a new localized one instead of relocalizing the existing expression (which would cause it to become more deeply nested): NSExpression *localizedCoalescingExpressionMarker = [NSExpression expressionForKeyPath:@"com.mapbox.expressions.localized"];
if ([self.function isEqualToString:@"mgl_coalesce:"]) {
// Check if the coalescing expression was the result of previously localizing an expression.
NSArray *coalescedExpressions = (NSArray *)self.arguments.firstObject;
if ([coalescedExpressions isKindOfClass:[NSArray array]] &&
[coalescedExpressions.lastObject isEqual:localizedCoalescingExpressionMarker]) {
// If so, replace the expression instead of relocalizing it.
return [[NSExpression expressionForKeyPath:@"name"]
mgl_expressionLocalizedIntoLocale:locale];
}
}
NSArray *localizedArguments = MGLLocalizedCollection(arguments, locale);
// … |
Fixed in #12387. |
When the system language is set to Simplified Chinese, labels of countries, states and provinces, and oceans and seas disappear instead of being localized into Simplified Chinese. This is because
+[MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:]
assumes all Streets source layers offer the same languages. In fact, this documentation says (in a rather confusing way) thatname_zh-Hans
is unavailable for thecountry_label
,state_label
, andmarine_label
layers.The language fallback logic being added for #11867 could address this issue, but a more targeted fix would involve special-casing these three source layers.
/ref #11867
/cc @friedbunny @nickidlugash @langsmith
The text was updated successfully, but these errors were encountered: