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

More robust Mapbox Streets label localization #9063

Merged
merged 1 commit into from
May 23, 2017

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented May 21, 2017

Rely on NSBundle to select the most appropriate locale based on the user’s preferred languages. This code is used in iosapp’s “Label Countries In” demonstration and macosapp’s View ‣ Labels In setting. (#7031 tracks folding that logic into the SDKs proper.)

Added Arabic, Portuguese, and Simplified Chinese to the list of languages with specialized fields in the Mapbox Streets source, based on this revised document. The previous logic was insufficient for choosing between zh and zh-Hans.

/cc @friedbunny

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.
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS labels May 21, 2017
@1ec5 1ec5 self-assigned this May 21, 2017
@1ec5 1ec5 requested a review from friedbunny May 21, 2017 02:49
forPreferences:[NSLocale preferredLanguages]];
NSString *mostSpecificLanguage;
for (NSString *language in preferredLanguages) {
if (language.length > mostSpecificLanguage.length) {
Copy link
Contributor

@friedbunny friedbunny May 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How robust do you think picking the longest match is? I suppose we’d have to rethink this a bit if we ever added support for, e.g., zh-Hant.

Copy link
Contributor Author

@1ec5 1ec5 May 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sort of a hack to prioritize zh-Hans in the case where the preference is zh-*. Confusingly, the +[NSBundle preferredLocalizationsFromArray:forPreferences:] documentation claims that the method in this case returns:

typically either a single non-region-specific localization or a region-specific localization followed by a corresponding non-region-specific localization as a fallback

whereas preferredLanguages actually ends up with the value ["zh", "zh-Hans"].

Unfortunately, it is the case that, when the preference is zh-Hant or zh-Hant-*, preferredLanguages ends up being ["en"]. If we do add a zh-Hant, zh-Hant-TW will correctly match zh-Hant, however.

/ref lionheart/openradar-mirror#4831 (rdar://problem/14228383)

@boundsj boundsj added this to the ios-v3.6.0 milestone May 23, 2017
@1ec5 1ec5 merged commit c9de6cd into release-ios-v3.6.0-android-v5.1.0 May 23, 2017
@1ec5 1ec5 deleted the 1ec5-streets-langs-zh branch May 23, 2017 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants