chore: Cleanup scandic-web * Remove unused files * Remove unused and add missing packages * Remove unused exports Approved-by: Linus Flood
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { Lang } from "@scandic-hotels/common/constants/language"
|
|
import { ApiLang } from "@scandic-hotels/trpc/constants/apiLang"
|
|
|
|
export const languages: Record<Lang, string> = {
|
|
[Lang.da]: "Dansk",
|
|
[Lang.de]: "Deutsch",
|
|
[Lang.en]: "English",
|
|
[Lang.fi]: "Suomi",
|
|
[Lang.no]: "Norsk",
|
|
[Lang.sv]: "Svenska",
|
|
}
|
|
|
|
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,
|
|
}
|
|
})
|
|
}
|