teecup/frontend/lib/locale.ts

13 lines
629 B
TypeScript
Raw Normal View History

// i18n (ADR-094) -- delte, RENE konstanter (ingen next/headers eller
// next-intl/server-import) slik at både server-only i18n/request.ts OG
// klientkomponenter (locale-bootstrap.tsx/language-switcher.tsx) kan
// importere dem uten å dra server-only-kode inn i klientbunten.
export const SUPPORTED_LOCALES = ["nb", "en"] as const
export type Locale = (typeof SUPPORTED_LOCALES)[number]
export const DEFAULT_LOCALE: Locale = "nb"
export const LOCALE_COOKIE = "locale"
export function isLocale(value: string | undefined | null): value is Locale {
return !!value && (SUPPORTED_LOCALES as readonly string[]).includes(value)
}