first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
14
apps/web/modules/i18n/lib/locale-cookie.ts
Normal file
14
apps/web/modules/i18n/lib/locale-cookie.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import "server-only";
|
||||
|
||||
import { config } from "@repo/config";
|
||||
import type { Locale } from "@repo/i18n";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function getUserLocale() {
|
||||
const cookie = (await cookies()).get(config.i18n.localeCookieName);
|
||||
return cookie?.value ?? config.i18n.defaultLocale;
|
||||
}
|
||||
|
||||
export async function setLocaleCookie(locale: Locale) {
|
||||
(await cookies()).set(config.i18n.localeCookieName, locale);
|
||||
}
|
||||
10
apps/web/modules/i18n/lib/update-locale.ts
Normal file
10
apps/web/modules/i18n/lib/update-locale.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
"use server";
|
||||
|
||||
import { setLocaleCookie } from "@i18n/lib/locale-cookie";
|
||||
import type { Locale } from "@repo/i18n";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function updateLocale(locale: Locale) {
|
||||
await setLocaleCookie(locale);
|
||||
revalidatePath("/");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue