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

Automatically adapt Mapbox Streets–sourced layers for user preferred language #7031

Closed
1ec5 opened this issue Nov 11, 2016 · 11 comments
Closed
Assignees
Labels
feature GL JS parity For feature parity with Mapbox GL JS Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS runtime styling
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Nov 11, 2016

When a user adjusts the Preferred Language Order setting in the Language & Region section of Settings to a language supported by the Mapbox Streets source, any style based on the Mapbox Streets source should automatically adjust by localizing the labels.

MGLMapView can observe NSCurrentLocaleDidChangeNotification and respond by obtaining NSLocale.autoupdatingCurrentLocale, determining the identifiers of the sources whose URL matches mapbox://mapbox.mapbox-streets-v*, and replacing {name*} tokens in the textField of any MGLSymbolStyleLayer whose sourceIdentifier is one of those source identifiers. We already do something similar in iosapp on demand: #6819.

We could also offer a way to extend this feature to arbitrary sources, by allowing the developer to specify which fields in the source correspond to which languages (see also mapbox/DEPRECATED-mapbox-gl#21).

Iterating over all the sources and style layers will require #6097. Discovering whether a source is Mapbox Streets will require #6584. #7030 would rely on a similar mechanism.

/ref #1108
/cc @incanus @pveugen @boundsj @frederoni

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling labels Nov 11, 2016
@1ec5 1ec5 self-assigned this Nov 11, 2016
@1ec5 1ec5 added Google Maps parity For feature parity with the Google Maps SDK for Android or iOS MapKit parity For feature parity with MapKit on iOS or macOS labels Nov 11, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Nov 11, 2016

We should expose an option on MGLStyle that allows the developer to turn automatic localization on and off (for supported sources). I think it should be on by default, for parity with MapKit and the Google Maps SDK, but there definitely needs to be a way to turn the feature off, in case the developer wants a specific language to be displayed.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 24, 2017

Note that macosapp already performs this automatic localization, as of #6097 and #7398, so this ticket tracks upstreaming that code to the iOS and macOS SDKs.

@evgzor
Copy link

evgzor commented Jun 19, 2017

Are any estimations when the issue would be fixed?

@friedbunny friedbunny modified the milestones: ios-v3.6.1, ios-v3.6.2 Aug 1, 2017
@boundsj
Copy link
Contributor

boundsj commented Aug 2, 2017

This was done in #9582 on the release-ios-v3.6.0-android-v5.1.0 branch and is expected to be in the 3.6.2 release. cc @fabian-guerra

@boundsj boundsj closed this as completed Aug 2, 2017
@evgzor
Copy link

evgzor commented Aug 9, 2017

@boundsj Could u please provide any estimation when 3.6.2 would be released?

@boundsj
Copy link
Contributor

boundsj commented Aug 10, 2017

@evgzor patch releases for v3.6.x are going out every 2 to three weeks so it should be this week or next.

@evgzor
Copy link

evgzor commented Aug 28, 2017

@boundsj please look:

screen shot 2017-08-28 at 13 59 34

Localization still does not work on iOS for German language.

@fabian-guerra
Copy link
Contributor

Hi @evgzor did you set mapView.style.localizesLabels to YES?

localize

@friedbunny
Copy link
Contributor

did you set mapView.style.localizesLabels to YES?

Additionally, this should be done in -[MGLMapViewDelegate mapView:didFinishLoadingStyle:] or later.

@evgzor
Copy link

evgzor commented Sep 1, 2017

@friedbunny @fabian-guerra on iOS all good but on Android Mapbox 5.1.3 still an issue:
device-2017-09-01-134409
Could u help me and tell what could be wrong?

@Guardiola31337
Copy link
Contributor

Hey @evgzor 👋

That feature is not included in the Android binding and the idea to cover that functionality is implementing it as a plugin.
👀 mapbox/mapbox-plugins-android#36

That ticket is still opened so in the meantime you could do it manually:

Locale.getDefault().getDisplayLanguage();
  • Change label language dynamically
Layer mapText = map.getLayer("place-city-lg-n");
mapText.setProperties(textField("{name_ru}"));

If you know the language in advance you could directly change label language as shown above ☝️

For further information check Change your map’s label language and the language switch example.

Contributions are more than welcome so I encourage you to take a stab at mapbox/mapbox-plugins-android#36 and send a PR fixing it (follow the steps mentioned above) 😛

Thanks Eugene!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature GL JS parity For feature parity with Mapbox GL JS Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS runtime styling
Projects
None yet
Development

No branches or pull requests

6 participants