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
34 lines
963 B
TypeScript
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,
|
|
}
|
|
})
|
|
}
|