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

Label localization prioritizes other languages over English despite user preference #11906

Closed
1ec5 opened this issue May 14, 2018 · 1 comment
Labels
bug iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented May 14, 2018

As of #11651, if the Preferred Languages setting lists English followed by another language that the Mapbox Streets source includes, such as French, -[MGLStyle localizeLabelsIntoLocale:] prefers that other language instead of English.

The following code will only ever resolve to English if none of the languages in MGLMapboxStreetsAlternativeLanguages (which swaps out en for mul) match the preference:

NSArray<NSString *> *preferredLanguages = [NSBundle preferredLocalizationsFromArray:MGLMapboxStreetsAlternativeLanguages
forPreferences:preferencesArray];
NSString *mostSpecificLanguage;
for (NSString *language in preferredLanguages) {
if (language.length > mostSpecificLanguage.length) {
mostSpecificLanguage = language;
}
}
if ([mostSpecificLanguage isEqualToString:@"mul"]) {
return acceptsEnglish ? @"en" : nil;
}

This logic was introduced because NSBundle prefers English over mul as a last resort. We should add a special case for English being above mostSpecificLanguage in preferencesArray.

/cc @bsudekum @friedbunny

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS localization Human language support and internationalization labels May 14, 2018
@1ec5 1ec5 modified the milestones: ios-v4.0.2, ios-v4.0.1 May 14, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented May 14, 2018

Fixed in #11907 on the release-boba branch for iOS map SDK v4.0.1 and macOS map SDK v0.7.1.

@1ec5 1ec5 closed this as completed May 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

No branches or pull requests

1 participant