diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-09-11 22:57:35 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-11-02 15:19:55 -0700 |
commit | 83acd62a4c425b69bc7aa68dce1439d8125e325c (patch) | |
tree | a5c4bd17b059f8173890a41669c1e7c4df924a8b | |
parent | 160da060963548e6e87886ccd493579ccd92a5fd (diff) | |
download | qtlocation-mapboxgl-83acd62a4c425b69bc7aa68dce1439d8125e325c.tar.gz |
[ios] Romanize feature names
-rw-r--r-- | platform/ios/src/MGLMapAccessibilityElement.m | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/platform/ios/src/MGLMapAccessibilityElement.m b/platform/ios/src/MGLMapAccessibilityElement.m index a592a9bcd8..0fca75c0a5 100644 --- a/platform/ios/src/MGLMapAccessibilityElement.m +++ b/platform/ios/src/MGLMapAccessibilityElement.m @@ -76,9 +76,20 @@ CLLocationDirection MGLDirectionBetweenCoordinates(CLLocationCoordinate2D firstC if (self = [super initWithAccessibilityContainer:container]) { _feature = feature; - NSString *nameAttribute = [NSString stringWithFormat:@"name_%@", - [MGLVectorSource preferredMapboxStreetsLanguage]]; - self.accessibilityLabel = [feature attributeForKey:nameAttribute]; + NSString *languageCode = [MGLVectorSource preferredMapboxStreetsLanguage]; + NSString *nameAttribute = [NSString stringWithFormat:@"name_%@", languageCode]; + NSString *name = [feature attributeForKey:nameAttribute]; + + // If a feature hasn’t been translated into the preferred language, it + // may be in the local language, which may be written in another script. + // Romanize it. + NSLocale *locale = [NSLocale localeWithLocaleIdentifier:languageCode]; + NSString *scriptCode = [locale objectForKey:NSLocaleScriptCode]; + if ([scriptCode isEqualToString:@"Latn"]) { + name = [name stringByApplyingTransform:NSStringTransformToLatin reverse:NO]; + } + + self.accessibilityLabel = name; } return self; } |