diff options
Diffstat (limited to 'platform/darwin/src/NSExpression+MGLAdditions.mm')
-rw-r--r-- | platform/darwin/src/NSExpression+MGLAdditions.mm | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index 04152afffd..527cb64b3d 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -1398,12 +1398,16 @@ NSDictionary<NSNumber *, NSExpression *> *MGLLocalizedStopDictionary(NSDictionar - (NSExpression *)mgl_expressionLocalizedIntoLocale:(nullable NSLocale *)locale { switch (self.expressionType) { case NSConstantValueExpressionType: { - NSDictionary *stops = self.constantValue; - if ([stops isKindOfClass:[NSDictionary class]]) { - NSDictionary *localizedStops = MGLLocalizedStopDictionary(stops, locale); - if (localizedStops != stops) { + if ([self.constantValue isKindOfClass:[NSDictionary class]]) { + NSDictionary *localizedStops = MGLLocalizedStopDictionary(self.constantValue, locale); + if (localizedStops != self.constantValue) { return [NSExpression expressionForConstantValue:localizedStops]; } + } else if ([self.constantValue isKindOfClass:[NSArray class]]) { + NSArray *localizedValues = MGLLocalizedCollection(self.constantValue, locale); + if (localizedValues != self.constantValue) { + return [NSExpression expressionForConstantValue:localizedValues]; + } } return self; } @@ -1422,19 +1426,18 @@ NSDictionary<NSNumber *, NSExpression *> *MGLLocalizedStopDictionary(NSDictionar if ([localizedKeyPath isEqualToString:@"name"]) { return [NSExpression expressionForKeyPath:localizedKeyPath]; } - // If the keypath is `name_zh-Hans`, fallback to `name_zh` to `name` - // The `name_zh-Hans` field was added since Mapbox Streets v7 - // See the documentation of name fields for detail https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#overview - // CN tiles might using `name_zh-CN` for Simplified Chinese + // If the keypath is `name_zh-Hans`, fallback to `name_zh` to `name`. + // CN tiles might using `name_zh-CN` for Simplified Chinese. if ([localizedKeyPath isEqualToString:@"name_zh-Hans"]) { return [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K, %K, %K})", localizedKeyPath, @"name_zh-CN", @"name_zh", @"name"]; } - // Mapbox Streets v8 has `name_zh-Hant`, we should fallback to Simplified Chinese if the filed has no value + // Mapbox Streets v8 has `name_zh-Hant`, we should fallback to Simplified Chinese if the field has no value. if ([localizedKeyPath isEqualToString:@"name_zh-Hant"]) { return [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K, %K, %K, %K})", localizedKeyPath, @"name_zh-Hans", @"name_zh-CN", @"name_zh", @"name"]; } + // Other keypath fallback to `name` return [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", localizedKeyPath, @"name"]; } |