Files
edr-platform/apps/edr-freight-web/backoffice/src/shared/i18n/uiLanguages.ts
natib21 e6e44e773b fix ui
2026-07-10 11:25:59 +00:00

43 lines
1.1 KiB
TypeScript

export const UI_LANGUAGE_OPTIONS = [
{ value: "en", label: "English", nativeName: "English" },
{ value: "am", label: "አማርኛ", nativeName: "Amharic" },
{ value: "fr", label: "Français", nativeName: "French" },
] as const;
export type UiLanguageCode = (typeof UI_LANGUAGE_OPTIONS)[number]["value"];
export function resolveUiLanguage(language?: string | null): UiLanguageCode {
if (!language) return "en";
if (language.startsWith("am")) return "am";
if (language.startsWith("fr")) return "fr";
return "en";
}
export function getUiLanguageLabel(
language: UiLanguageCode,
t: (key: string) => string,
): string {
switch (language) {
case "am":
return t("header.amharic");
case "fr":
return t("header.french");
default:
return t("header.english");
}
}
export function getUiLanguageShortLabel(
language: UiLanguageCode,
t: (key: string) => string,
): string {
switch (language) {
case "am":
return t("header.amharicShort");
case "fr":
return t("header.frenchShort");
default:
return t("header.englishShort");
}
}