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

Implement language switching in URL querystring #20

Closed
ZeLonewolf opened this issue Jul 7, 2021 · 3 comments · Fixed by #581
Closed

Implement language switching in URL querystring #20

ZeLonewolf opened this issue Jul 7, 2021 · 3 comments · Fixed by #581
Assignees

Comments

@ZeLonewolf
Copy link
Member

ZeLonewolf commented Jul 7, 2021

Depends on #19

A key feature of vector tiles is the ability to switch languages for name labels. OpenMapTiles provides name:xx tags wherever a name tag is available. Proposed is that the following parameters can be parsed from the querystring:

*lang0=xx - use name:xx tag for name features
*langN=xx - use name:xx as a fallback language if the lang0 language is not available. N is numbered from 1 and counting up

If none of the specified languages or fallback languages are set, this will default to one of the standard name values (one of name, name_int, or name_latin).

In javascript, a JSON fragment will need to be generated which creates a case statement to switch the specified language names, which is then inserted into the appropriate locations in the style JSON variables.

@ZeLonewolf
Copy link
Member Author

The following library may be of use:
https://github.com/klokantech/openmaptiles-language

@1ec5
Copy link
Member

1ec5 commented Nov 27, 2022

The following library may be of use: https://github.com/klokantech/openmaptiles-language

This script predates expressions and uses the deprecated string interpolation syntax, so it’s incompatible with this project. It also isn’t distributed as an NPM package. There is a compatible Mapbox GL JS library for localizing labels. However, I don’t think a library is necessary at all. Unlike most styles that are distributed in static JSON format, Americana is built at runtime in JavaScript, giving us the ability to inject environment variables like the language as we build each layer. #578 implements this approach without needing to hard-code a single name:* field.

#578 relies on user preferences, but I agree that it would be handy to be able to set the language inside the URL. There are two typical approaches to implementing a URL-based language switch:

@1ec5 1ec5 added the blocked label Nov 27, 2022
@1ec5 1ec5 removed their assignment Nov 27, 2022
@1ec5 1ec5 removed the blocked label Nov 27, 2022
@1ec5 1ec5 self-assigned this Nov 27, 2022
@jleedev
Copy link
Member

jleedev commented Nov 27, 2022

Can also switch to esbuild's serve api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants