Feat/SW-1379 multiroom summary * fix: added early return in hotel query and added missing type annotations * feat(SW-1379): update summary to support multiple rooms and add tests * fix: added check for room number when using isMember for member prices * fix: remove mocked array * fix: minor bug fixes in rate details popup * fix: translation key Approved-by: Pontus Dreij Approved-by: Arvid Norlin
33 lines
676 B
TypeScript
33 lines
676 B
TypeScript
import "server-only"
|
|
|
|
import { createIntl, createIntlCache } from "@formatjs/intl"
|
|
import { headers } from "next/headers"
|
|
|
|
import { Lang } from "@/constants/languages"
|
|
|
|
const cache = createIntlCache()
|
|
|
|
export async function initIntl(lang: Lang) {
|
|
return createIntl<React.ReactNode>(
|
|
{
|
|
defaultLocale: Lang.en,
|
|
locale: lang,
|
|
messages: (await import(`./dictionaries/${lang}.json`)).default,
|
|
},
|
|
cache
|
|
)
|
|
}
|
|
|
|
export async function getIntl(forceLang?: Lang) {
|
|
const h = headers()
|
|
let lang = h.get("x-lang") as Lang
|
|
if (!lang) {
|
|
lang = Lang.en
|
|
}
|
|
|
|
if (forceLang) {
|
|
return await initIntl(forceLang)
|
|
}
|
|
return await initIntl(lang)
|
|
}
|