Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Romanize feature names
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Sep 12, 2017
1 parent 23b03f7 commit 1464eac
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions platform/ios/src/MGLMapAccessibilityElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,20 @@ - (instancetype)initWithAccessibilityContainer:(id)container feature:(id<MGLFeat
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;
}
Expand Down

0 comments on commit 1464eac

Please sign in to comment.