summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-05-20 19:44:52 -0700
committerMinh Nguyễn <mxn@1ec5.org>2017-05-23 10:09:48 -0700
commitc9de6cdb6c8b4a640c10940adbd76ed508900022 (patch)
tree3509bc9021bcaf004a1b3d5656d68da0c8b4a145 /platform/ios
parenta57e9bc41093eb8f028dcab3593c3921d887bdc0 (diff)
downloadqtlocation-mapboxgl-c9de6cdb6c8b4a640c10940adbd76ed508900022.tar.gz
[ios, macos] More robust Streets localization
Added Arabic, Portuguese, and Simplified Chinese to the list of languages with specialized fields in the Mapbox Streets source. Rely on NSBundle to select the most appropriate locale based on the user’s preferred languages.
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/app/MBXViewController.m21
1 files changed, 11 insertions, 10 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 209998adb9..d3927374a7 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -1397,19 +1397,20 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
- (NSString *)bestLanguageForUser
{
- NSArray *supportedLanguages = @[ @"en", @"es", @"fr", @"de", @"ru", @"zh" ];
- NSArray<NSString *> *preferredLanguages = [NSLocale preferredLanguages];
- NSString *bestLanguage;
-
- for (NSString *language in preferredLanguages) {
- NSString *thisLanguage = [[NSLocale localeWithLocaleIdentifier:language] objectForKey:NSLocaleLanguageCode];
- if ([supportedLanguages containsObject:thisLanguage]) {
- bestLanguage = thisLanguage;
- break;
+ // https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#overview
+ NSArray *supportedLanguages = @[ @"ar", @"en", @"es", @"fr", @"de", @"pt", @"ru", @"zh", @"zh-Hans" ];
+ NSArray<NSString *> *preferredLanguages = [NSBundle preferredLocalizationsFromArray:supportedLanguages forPreferences:[NSLocale preferredLanguages]];
+ NSString *mostSpecificLanguage;
+
+ for (NSString *language in preferredLanguages)
+ {
+ if (language.length > mostSpecificLanguage.length)
+ {
+ mostSpecificLanguage = language;
}
}
- return bestLanguage ?: @"en";
+ return mostSpecificLanguage ?: @"en";
}
- (IBAction)startWorldTour