You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Frontend changes to support multilingual labels #878
More recently, Minh did the work on the embed site to make Mabox GL Language work. This was a little tricky, so reference his code: OpenHistoricalMap/openhistoricalmap-embed#8
Some notes from conversation with Eric, which he will add details to:
Initial work on this has not been successful so far, so nothing has been committed
On theory is that because we're not using a MapLibre Map but instead a Leaflet plugin, some tings are not handled by that plugin and that's causing issues.
@erictheise will post more details here so we can get more brains on this problem.
On theory is that because we're not using a MapLibre Map but instead a Leaflet plugin, some tings are not handled by that plugin and that's causing issues.
openstreetmap/openstreetmap-website#4042 is successfully using the same plugin with Leaflet. I wonder if it’s basically a race condition. We seem to have a lot of our map customizations tied to the time slider loading: #915.
The wording and API at the repo for maplibre-gl-leaflet made me wonder if it supported what we're trying to do here but Minh points out above that it must.
Conceptually, any runtime styling modifications for localizing labels need to happen at about the same time that we first apply the date filter to the map. As long as that happens early enough, Leaflet should pick up the modifications along with the date filter. However, if it happens too late, it’s possible that Leaflet will take some time to reflect the changes, if at all. I’ve seen that happen sporadically with the date filter too, but it isn’t very deterministic.
Instead of enumerating all the supported languages, as MapTiler did in their PR, openhistoricalmap-embed passes in a function that resolves the language field on the fly:
The embed site accepts any string of any length in the language param. I believe the main site should perform a validation on the string before adding it to a user's language.supportedLanguages. I was going to propose a regex based on RFC 5646 and see that we may already have one as a result of the discussion in 948.
A similar validation should be in place when edits are received.
For the embed site, the only impact of specifying an invalid language parameter is that everything falls back to multilingual labels, as if you had specified mul. (Ideally, everything would fall back to the next language in the list, on a feature by feature basis, but mapbox-gl-language doesn’t support that.)
Anyways, I don’t think that has anything to do with why Hindi isn’t working. The screenshot shows that the preference is correctly set to hi.
@jeffreyameyer noticed that the map crashes on an uncaught exception when you set the language to a valid code that isn’t supported by Mapbox Streets, such as zh (Chinese, but without specifying a script).
@jeffreyameyer noticed that the map crashes on an uncaught exception when you set the language to a valid code that isn’t supported by Mapbox Streets, such as zh (Chinese, but without specifying a script).
I added many new labels to the testbed as part of #1050 today. That work has not made it to the staging tiles so all I can offer is screenshots of my dev environment using production tiles. This is the area at /#map=16/70.01184/-42.33122&layers=O&date=1925-05-13&daterange=1825-01-01,2025-12-31 and you will see that the various types of waterways and the one town pick up and properly display the labels.
Activity
danrademacher commentedon Nov 22, 2024
Some notes from conversation with Eric, which he will add details to:
@erictheise will post more details here so we can get more brains on this problem.
1ec5 commentedon Nov 23, 2024
openstreetmap/openstreetmap-website#4042 is successfully using the same plugin with Leaflet. I wonder if it’s basically a race condition. We seem to have a lot of our map customizations tied to the time slider loading: #915.
danrademacher commentedon Dec 3, 2024
@erictheise can you please add the notes we talked about your adding here?
erictheise commentedon Dec 3, 2024
My attention has been on upstream catchup but the last thing I tried was adding
at the beginning of
app/assets/javascripts/leaflet.map.jsand incorporatinginto the push of the historical layer at https://github.com/OpenHistoricalMap/ohm-website/blob/43b6c1bf455a92eb1b4969c18ffd83c2d63f95ba/app/assets/javascripts/leaflet.map.js#L86
erictheise commentedon Dec 3, 2024
I started down the path of incorporating the maptiler code in openstreetmap/openstreetmap-website#4042 but worried we'd regret it later. That pull request is a year and half old and seemed unlikely to be incorporated into upstream but apparently it is still under discussion and may be moving forward. See https://osmfoundation.org/wiki/Operations/Minutes/2024-10-31#OpenMapTiles_application
erictheise commentedon Dec 3, 2024
My earliest attempt instantiated a MaplibreGL with the mechanisms in https://github.com/maptiler/openstreetmap-website/blob/888767144630f56340097450c362edc639a771d8/app/assets/javascripts/leaflet.map.js#L19-L49, then pushed that into all of our styles which seemed like the right way to go but although I got it to a point where it loaded without error it produced no visible effect on maps.
My IDE frustratingly seems not to have kept the memory of that work but I should be able to reconstruct it.
erictheise commentedon Dec 3, 2024
The wording and API at the repo for maplibre-gl-leaflet made me wonder if it supported what we're trying to do here but Minh points out above that it must.
1ec5 commentedon Dec 3, 2024
Conceptually, any runtime styling modifications for localizing labels need to happen at about the same time that we first apply the date filter to the map. As long as that happens early enough, Leaflet should pick up the modifications along with the date filter. However, if it happens too late, it’s possible that Leaflet will take some time to reflect the changes, if at all. I’ve seen that happen sporadically with the date filter too, but it isn’t very deterministic.
1ec5 commentedon Dec 5, 2024
Instead of enumerating all the supported languages, as MapTiler did in their PR, openhistoricalmap-embed passes in a function that resolves the language field on the fly:
https://github.com/OpenHistoricalMap/openhistoricalmap-embed/blob/ebb1dffd130be4bfe5d9f72dcca131682925df62/index.js#L52-L60
Initially, it has to insist that the current language is supported, whatever it is:
https://github.com/OpenHistoricalMap/openhistoricalmap-embed/blob/ebb1dffd130be4bfe5d9f72dcca131682925df62/index.js#L50
9 remaining items
erictheise commentedon May 8, 2025
The embed site accepts any string of any length in the
languageparam. I believe the main site should perform a validation on the string before adding it to a user'slanguage.supportedLanguages. I was going to propose a regex based on RFC 5646 and see that we may already have one as a result of the discussion in 948.A similar validation should be in place when edits are received.
1ec5 commentedon May 8, 2025
For the embed site, the only impact of specifying an invalid
languageparameter is that everything falls back to multilingual labels, as if you had specifiedmul. (Ideally, everything would fall back to the next language in the list, on a feature by feature basis, but mapbox-gl-language doesn’t support that.)Anyways, I don’t think that has anything to do with why Hindi isn’t working. The screenshot shows that the preference is correctly set to
hi.1ec5 commentedon May 9, 2025
@jeffreyameyer noticed that the map crashes on an uncaught exception when you set the language to a valid code that isn’t supported by Mapbox Streets, such as
zh(Chinese, but without specifying a script).OpenHistoricalMap/ohm-website#289 (comment) is the fix for this issue.
Re: OpenHistoricalMap/issues#878, addressing PR comments by removing …
erictheise commentedon May 13, 2025
I was not able to duplicate this on staging.
erictheise commentedon May 13, 2025
I added many new labels to the testbed as part of #1050 today. That work has not made it to the staging tiles so all I can offer is screenshots of my dev environment using production tiles. This is the area at
/#map=16/70.01184/-42.33122&layers=O&date=1925-05-13&daterange=1825-01-01,2025-12-31and you will see that the various types of waterways and the one town pick up and properly display the labels.en (and zh):
de:
ru:
cs:
el:
erictheise commentedon May 13, 2025
I left the
console.infostatements in on purpose to help with debugging if people have questions but they should come out after a few iterations.erictheise commentedon May 14, 2025
Verified via the testbed that multilingual labels are working in production.
Elaws commentedon May 26, 2025
Hi,
With language settings defined as :
Map labels still display in their original language :
Is this expected behavior ? Is their a way to display these labels in French or English ?
Thank you very much.
1ec5 commentedon May 27, 2025
Thanks for noticing – that’s a known issue, now tracked in #1068.