Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize labels dynamically #581

Merged
merged 5 commits into from
Nov 27, 2022
Merged

Localize labels dynamically #581

merged 5 commits into from
Nov 27, 2022

Conversation

1ec5
Copy link
Member

@1ec5 1ec5 commented Nov 27, 2022

The format of the hash at the end of the application’s URL has changed from #zoom/latitude/longitude to #map=zoom/latitude/longitude, which is consistent with both openstreetmap.org and iD. For easier map sharing and debugging, the application now accepts a language= parameter as part of the hash. For example, #map=12/29.95/-90.08 zooms to New Orleans, but #language=fr&map=12/29.95/-90.08 zooms to La Nouvelle Orléans, and #language=vi,es&map=12/29.95/-90.08 zooms to Nueva Orleans.

The application is now capable of rebuilding the entire style at an arbitrary time after the page loads. It rebuilds the style any time the user’s language preference changes or the URL hash’s language parameter changes. The only dynamic part of the style is label localization. Rebuilding the layers is challenging because of the codebase’s extensive use of global variables, but this PR uses a metadata field to persist an indication of the intention to localize a given layer’s text-field property, which is resolved just before setting the style.

Fixes #20 and fixes #579.

@1ec5 1ec5 added enhancement New feature or request internationalization labels Nov 27, 2022
@1ec5 1ec5 self-assigned this Nov 27, 2022
Copy link
Member

@claysmalley claysmalley left a comment

Choose a reason for hiding this comment

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

Fantastic work!

@ZeLonewolf ZeLonewolf merged commit bdf74fd into main Nov 27, 2022
@ZeLonewolf ZeLonewolf deleted the 1ec5-setlang-579 branch November 27, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update label language when user language preference changes Implement language switching in URL querystring
3 participants