Files
web/apps/scandic-web/constants/languages.ts
Hrishikesh Vaipurkar d3368e9b85 Merged in feat/SW-2782-create-sas-branded-header (pull request #2878)
feat(SW-2782): Updated header as per design, added language switcher and user menu

* feat(SW-2782): Updated header as per design, added language switcher and user menu

* feat(SW-2782): Updated UI as per design

* feat(SW-2782): Optimised code with use of Popover and modal from RAC


Approved-by: Anton Gunnarsson
2025-10-06 08:46:26 +00:00

34 lines
963 B
TypeScript

import { ApiLang } from "@scandic-hotels/trpc/constants/apiLang"
import type { Lang } from "@scandic-hotels/common/constants/language"
const languageSelect = [
{ label: "Danish", value: ApiLang.Da },
{ label: "German", value: ApiLang.De },
{ label: "English", value: ApiLang.En },
{ label: "Finnish", value: ApiLang.Fi },
{ 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,
}
})
}