// Language helpers shared by the editors (the PageEditor language picker, // the localization settings tab). Flags come from the country-flag-icons // set, same as the analytics visitor cells. import * as flagSvgs from 'country-flag-icons/string/3x2' // The Seed-X reference translator's languages (scripts/translator.py) — the // translation-target ceiling — each mapped to the country whose flag stands // for it (CLDR likely-subtag regions: the country with the most speakers). export const TRANSLATABLE = { ar: 'EG', cs: 'CZ', da: 'DK', de: 'DE', el: 'GR', en: 'US', es: 'ES', fa: 'IR', fi: 'FI', fr: 'FR', hu: 'HU', id: 'ID', it: 'IT', ja: 'JP', ko: 'KR', ms: 'MY', nl: 'NL', no: 'NO', pl: 'PL', pt: 'BR', ro: 'RO', ru: 'RU', sv: 'SE', th: 'TH', tr: 'TR', uk: 'UA', vi: 'VN', zh: 'CN', } const displayNames = new Intl.DisplayNames(['en'], { type: 'language' }) // English display name for a language tag ("fi" -> "Finnish"). export function langName(tag) { try { return displayNames.of(tag) || tag } catch { return tag } } // Flag SVG string for a language tag: the explicit mapping first, then the // tag's most likely region (for languages outside the translatable list). export function flagFor(tag) { const country = TRANSLATABLE[tag] if (country) return flagSvgs[country] || '' try { return flagSvgs[new Intl.Locale(tag).maximize().region] || '' } catch { return '' } }