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
Labels should treat preferred languages as fallback list #1068
The localized labels implemented for #878 only respect the first language in the user’s preferred language list, either in the user account or in browser preferences. If a feature’s name is unavailable in that language, the map should fall back to the second language in the list, and so on, before the name (contemporary native name) property as a last resort fallback.
For example, Japan is tagged with name=* in Japanese, plus name:*=* in various languages, but not name:fr=* in French. If the user prefers fr en, the map shows a label in Japanese based on name=*. Instead, it should show the label in English based on name:en=*.
The current behavior is a limitation of the plugin we’re currently relying on: mapbox/mapbox-gl-language#4. This affects both the map on the main homepage and the embed site. OpenStreetMap Americana has built-in support for a more robust fallback mechanism. osm-americana/openstreetmap-americana#914 tracks separating this functionality from the Americana application as a standalone plugin so that OHM can reuse it. We’d like to use that plugin anyways in order to gloss the native name alongside the localized name: #799.
changed the title [-]Labels should fall back to secondary preferred languages[/-][+]Labels should treat preferred languages as fallback list[/+]on May 27, 2025
Actually, the embed site is getting lucky: instead of calling the plugin’s setLanguage method explicitly, it relies on the plugin’s own initialization code, which does strip the country code. But for whatever reason, it’s actually ignoring the configuration’s list of supported languages in favor of the built-in list. So the embed site doesn’t actually localize into non-Mapbox languages, such as Dutch. We definitely need to migrate off this plugin, but in the meantime, we can simplify the qualified locale code to only specify the language code: OpenHistoricalMap/ohm-website#292.
OpenHistoricalMap/openhistoricalmap-embed#39 replaces mapbox-gl-language with Diplomat, which correctly interprets the list as a fallback list. Once this is working on the embed site, we can bring it over to the main site too.
Activity
Elaws commentedon May 27, 2025
Even if preferrence is set to
en-US en, it doesn't fall back to english label. You really have to setenonly for it to show in english.[-]Labels should fall back to secondary preferred languages[/-][+]Labels should treat preferred languages as fallback list[/+]1ec5 commentedon May 27, 2025
I see, that’s another difference between the main map and the embed map: it doesn’t strip out the country code. We should replace the code added in OpenHistoricalMap/ohm-website#289 OpenHistoricalMap/ohm-website#291 with this code that’s been working all along:
https://github.com/OpenHistoricalMap/openhistoricalmap-embed/blob/8b1adab8294c6dce5f0f4fbbd26c31b23c6b5a33/index.js#L49-L63
1ec5 commentedon May 27, 2025
Actually, the embed site is getting lucky: instead of calling the plugin’s
setLanguagemethod explicitly, it relies on the plugin’s own initialization code, which does strip the country code. But for whatever reason, it’s actually ignoring the configuration’s list of supported languages in favor of the built-in list. So the embed site doesn’t actually localize into non-Mapbox languages, such as Dutch. We definitely need to migrate off this plugin, but in the meantime, we can simplify the qualified locale code to only specify the language code: OpenHistoricalMap/ohm-website#292.1ec5 commentedon Dec 23, 2025
OpenHistoricalMap/openhistoricalmap-embed#39 replaces mapbox-gl-language with Diplomat, which correctly interprets the list as a fallback list. Once this is working on the embed site, we can bring it over to the main site too.