Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(atlas): translate unvisited country names via the locale resolver (#1798)

Konstantinos Thermosab9ca4220a3f
diff --git a/client/src/pages/atlas/useAtlas.test.tsx b/client/src/pages/atlas/useAtlas.test.tsx
index 61bcb01d1..8fb0f016c 100644
--- a/client/src/pages/atlas/useAtlas.test.tsx
+++ b/client/src/pages/atlas/useAtlas.test.tsx
@@ -590,6 +590,28 @@ describe('useAtlas', () => {
expect(atlas.confirmAction).toEqual({ type: 'choose', code: 'DE', name: 'Germany' });
});
+ it('FE-HOOK-ATLAS-025b: an unvisited country is named by the locale resolver, not the English GeoJSON name (#1789)', async () => {
+ // GeoJSON only carries English names; marking an unvisited country must still use the
+ // account-language name, exactly as visited countries do.
+ await mountAtlas({
+ geo: {
+ type: 'FeatureCollection',
+ features: [
+ feature({ ISO_A2: 'FR', ADM0_A3: 'FRA', ISO_A3: 'FRA', NAME: 'France', ADMIN: 'France' }),
+ feature({ ISO_A2: 'DE', ADM0_A3: 'DEU', ISO_A3: 'DEU', NAME: 'GERMANY_EN_ONLY', ADMIN: 'GERMANY_EN_ONLY' }),
+ ],
+ },
+ });
+ await waitFor(() => expect(lf.geoJson.length).toBeGreaterThan(0));
+
+ const countryLayer = lf.geoJson[0] as MockGeoJson;
+ const de = countryLayer.entries.find((e) => (e.feature.properties as Record<string, string>).ISO_A2 === 'DE');
+
+ act(() => de!.layer.handlers.click({}));
+ expect(atlas.confirmAction).toEqual({ type: 'choose', code: 'DE', name: atlas.resolveName('DE') });
+ expect(atlas.confirmAction?.name).not.toBe('GERMANY_EN_ONLY');
+ });
+
it('FE-HOOK-ATLAS-026: plugin tint layers are drawn in their own pane and redrawn on theme change', async () => {
await mountAtlas({
geo: geoCountries,
diff --git a/client/src/pages/atlas/useAtlas.ts b/client/src/pages/atlas/useAtlas.ts
index 47b3a5c5a..3ee6fd583 100644
--- a/client/src/pages/atlas/useAtlas.ts
+++ b/client/src/pages/atlas/useAtlas.ts
@@ -417,7 +417,7 @@ export function useAtlas() {
const countryCode = a3ToA2Entry ? a3ToA2Entry[0] : (isoA2 && isoA2 !== '-99' ? isoA2 : null)
if (countryCode && countryCode !== '-99') {
country_layer_by_a2_ref.current[countryCode] = layer
- const name = feature.properties?.NAME || feature.properties?.ADMIN || resolveName(countryCode)
+ const name = resolveName(countryCode) || feature.properties?.NAME || feature.properties?.ADMIN || countryCode
layer.bindTooltip(`<div style="font-size:12px;font-weight:600">${name}</div>`, {
sticky: true, className: 'atlas-tooltip', direction: 'top', offset: [0, -10], opacity: 1
})