Merged in feat/LOY-155-localize-language-options-in-edit-profile-form (pull request #1490)

feat(LOY-155): Localize language options in edit profile form

* feat(LOY-155): Localize language options in edit profile form

* feat(LOY-155): Capitalize first letter of localized language options


Approved-by: Christian Andolf
This commit is contained in:
Chuma Mcphoy (We Ahead)
2025-03-06 14:57:26 +00:00
parent 8b8d883b0d
commit 4db75057f2
2 changed files with 27 additions and 2 deletions

View File

@@ -85,3 +85,24 @@ export const languageSelect = [
{ label: "Norwegian", value: ApiLang.No },
{ label: "Swedish", value: ApiLang.Sv },
]
/**
* Get localized language options based on the current lang.
*/
export function getLocalizedLanguageOptions(currentLang: Lang) {
const displayNames = new Intl.DisplayNames([currentLang], {
type: "language",
})
return languageSelect.map((option) => {
const localizedName = displayNames.of(option.value)
const capitalizedName = localizedName
? localizedName.charAt(0).toUpperCase() + localizedName.slice(1)
: option.label
return {
value: option.value,
label: capitalizedName,
}
})
}