diff --git a/library/maps/localize-labels.js b/library/maps/localize-labels.js index 25a72e733..6a5074f0f 100644 --- a/library/maps/localize-labels.js +++ b/library/maps/localize-labels.js @@ -61,7 +61,31 @@ export function localizeBasemapLabels(map, lang) { // English too, not the style's own bilingual labels ("Россия" under "Russia"): those drew every // native script at world view, so an English page fetched 13 extra glyph ranges (~600 KB, rega: // Prayer Progress 18 requests / 777 KB in en against 5 / 185 KB in ar). One language per label. - const next = ['coalesce', ['get', 'name:' + code], ['get', 'name:latin'], ['get', 'name']] + // ★ AND THE UNDERSCORE SPELLING, because one of our basemaps writes it that way. The galaxy + // style (research-dashboard, my-upg-100-list) is VersaTiles Colorful on the Shortbread schema, + // whose label keys are name_ar / name_de / name_en …, NOT name:ar. This chain only tried the + // colon spelling, so every one of its 43 label layers coalesced down to `name` — the ENDONYM — + // and a Russian page rendered 中国 and Türkiye while fetching a glyph range for every script on + // screen. The localizer was running and could not help, which is the failure that looks like a + // basemap problem and is really a key-name problem. + // + // MEASURED against the live tiles (six z3/z4 tiles across Europe, Asia and Africa, identical key + // sets): name_ar, name_de, name_el, name_en, name_es, name_fr, name_it, name_nl, name_pl, + // name_pt, name_uk. Of the eleven locales we ship that covers SEVEN — ar, de, en, es, fr, it, pt + // — in their own language, with no change to the basemap the Driver chose. + // + // hi, ro, ru and zh are genuinely absent from those tiles, so they take name_en: Latin script, + // one script, readable rather than mixed CJK and Devanagari endonyms. That is the same role + // name:latin already plays for the OpenFreeMap styles, which is why it sits in the same position + // rather than being a special case. + // + // Order matters and is not arbitrary: the colon spelling first so the OpenFreeMap styles behave + // exactly as before (their first entry still wins and nothing about them changes), then the + // underscore, then the two Latin fallbacks, then the local name. + const next = ['coalesce', + ['get', 'name:' + code], ['get', 'name_' + code], + ['get', 'name:latin'], ['get', 'name_en'], + ['get', 'name']] map.setLayoutProperty(layer.id, 'text-field', next) n++ }