Files
fristydev/lib/i18n/get-locale.ts
T
fristy 03b00358c0
Build & Push / Build & Push Image (push) Canceled after 0s
Build & Push / Lint & Build (push) Canceled after 41s
Initial commit: fristy.net personal site
2026-09-10 04:23:21 +03:00

12 lines
347 B
TypeScript

import { cookies } from "next/headers";
import { DEFAULT_LOCALE, LOCALE_COOKIE, isLocale, type Locale } from "./locales";
export async function getLocale(): Promise<Locale> {
const store = await cookies();
const raw = store.get(LOCALE_COOKIE)?.value;
if (raw && isLocale(raw)) {
return raw;
}
return DEFAULT_LOCALE;
}