Skip to content

Add Event: Location names stored in browser language, breaking cross-language text matching #6

@attixyz

Description

@attixyz

Description

When creating an event, the location field autocomplete saves the place name in the user's browser language. An Italian user searching "London" gets "Londra" stored in the event. An English user then searching "London" finds nothing — the text doesn't match.

Steps to reproduce

  1. Open the create event form with a browser set to Italian or other language
  2. Type "London" in the location field
  3. Select the first result
  4. The stored location string is "Londra, Greater London, Inghilterra, Regno Unito"

Root cause

FormGeoSearchField uses leaflet-geosearch's OpenStreetMapProvider with no accept-language parameter:

// src/components/common/form/FormGeoSearchField.tsx
return new OpenStreetMapProvider(); // no accept-language

leaflet-geosearch calls Nominatim via the browser's fetch. The browser automatically attaches an Accept-Language HTTP header (e.g. it for Italian), and Nominatim honours it — returning "Londra", "San Paolo", "Monaco di Baviera". This header cannot be suppressed or overridden from JavaScript (it is a forbidden header name); the only way to override it is via Nominatim's accept-language query parameter, which takes priority over the HTTP header.

There are 3 ways to fix this; number 1 in my opinion is the best:

Proposed fixes

  1. Bypass leaflet-geosearch and query Nominatim directly. leaflet-geosearch is a thin wrapper (URL builder + response mapper) — it adds no meaningful logic here beyond what a direct fetch provides. Querying directly gives full control over all params, removes the dependency, and also allows removing the unused leaflet-geosearch/dist/geosearch.css import.

  2. Force a non-existent language code in the provider params:

    new OpenStreetMapProvider({ params: { "accept-language": "xx" } })

    Nominatim fails to find a translation for xx and falls back to the place's local name field (e.g. "München", "Roma"). Simple one-liner, but relies on undocumented fallback behaviour.

  3. Add namedetails: 1 to the provider params:

    new OpenStreetMapProvider({ params: { namedetails: 1 } })

    Nominatim then includes a namedetails object in each result. raw.namedetails.name is always the local name, regardless of browser language. Downside: option.label (built from display_name) is still in the browser's language, so the display label would need to be reconstructed manually from raw fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions