Files
gods-eye-view/src/ui/placeNames.js
T
German KhokhlovandClaude Opus 5.5 20f4cf3763 i18n: fix the LGTM review findings and tidy the branch texts
- i18n scanner: lastError sink, no false sinks on defaults and ternaries
- shared src/i18n/marker.js for modules that only mark strings
- wind field messages move to wind/fields.js; CITY_POIS imports from cityPois.js
- drop review IDs, change history and stale references from comments and docs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 21:00:28 +04:00

45 lines
1.4 KiB
JavaScript

/**
* Preset place names as the page shows them.
*
* The preset cities in src/cityPois.js keep their English names in data:
* those are what voice tools, the AI model, share links and lookups match on.
* This helper translates a known English name at a presentation boundary
* only; any other place (a geocoded address, a name the model chose) is shown
* as given.
*
* Pure: imports only i18n, no DOM.
* @module ui/placeNames
*/
import { msg, t } from '../i18n/index.js';
// The preset cities (CITY_POIS names, kept in step by placeNames.test.mjs),
// and Los Angeles, which voice results name for the analyst's region scopes.
const PLACE_NAME_KEYS = new Map(
[
msg('Austin'),
msg('San Francisco'),
msg('New York'),
msg('Tokyo'),
msg('London'),
msg('Paris'),
msg('Dubai'),
msg('Washington DC'),
msg('Tallinn'),
msg('Los Angeles'),
].map((key) => [key, key]),
);
/**
* A preset place name in the active language; any other text unchanged.
* @param {string} name English place name, e.g. `Tokyo`.
* @returns {string}
*/
export function localizePlaceName(name) {
if (typeof name !== 'string') return name;
const key = PLACE_NAME_KEYS.get(name.trim());
return key ? t(key) : name;
}
/** The English names this module translates (for tests). */
export const KNOWN_PLACE_NAMES = Object.freeze([...PLACE_NAME_KEYS.keys()]);