mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-29 19:58:13 +00:00
feat: enhance location handling and localization; improve fallback mechanisms and unify type definitions
This commit is contained in:
@@ -183,7 +183,13 @@ export function localized(value: Bilingual | undefined, language = 'en'): string
|
||||
if (!value) return '';
|
||||
// `||` not `??`: an empty Amharic string is "not translated", not a value —
|
||||
// editors save `am: ''` freely (ExamPage, CertificationPage, LocationForm).
|
||||
return (language === 'am' ? value.am : value.en) || value.en || value.am || '';
|
||||
//
|
||||
// Keyed by the active language rather than an en/am ternary, so a locale the
|
||||
// backend stores but the UI does not yet offer a switcher for (`om`, `so` on
|
||||
// location names) still resolves once it does. English then Amharic remain
|
||||
// the fallbacks, in that order.
|
||||
const active = value[language as keyof Bilingual];
|
||||
return active || value.en || value.am || '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user