Skip to content

Labels should treat preferred languages as fallback list #1068

Description

@1ec5

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.

Originally reported in #878 (comment).

Activity

  1. added
    website
    internationalization
    on May 27, 2025
  2. added theissue type on May 27, 2025
  3. Elaws commented on May 27, 2025

    @Elaws

    Even if preferrence is set to en-US en, it doesn't fall back to english label. You really have to set en only for it to show in english.

  4. changed the title [-]Labels should fall back to secondary preferred languages[/-] [+]Labels should treat preferred languages as fallback list[/+] on May 27, 2025
  5. 1ec5 commented on May 27, 2025

    @1ec5
    MemberAuthor

    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

  6. changed the issue type fromtoon May 27, 2025
  7. changed the issue type fromtoon May 27, 2025
  8. 1ec5 commented on May 27, 2025

    @1ec5
    MemberAuthor

    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.

  9. 1ec5 commented on Dec 23, 2025

    @1ec5
    MemberAuthor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    internationalizationwebsite

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions