mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
17 lines
505 B
TypeScript
17 lines
505 B
TypeScript
'use server';
|
|
|
|
import {cookies} from 'next/headers';
|
|
import {Locale, defaultLocale} from '@/i18n/config';
|
|
|
|
// In this example the locale is read from a cookie. You could alternatively
|
|
// also read it from a database, backend service, or any other source.
|
|
const COOKIE_NAME = 'NEXT_LOCALE';
|
|
|
|
export async function getUserLocale() {
|
|
return (await cookies()).get(COOKIE_NAME)?.value || defaultLocale;
|
|
}
|
|
|
|
export async function setUserLocale(locale: Locale) {
|
|
(await cookies()).set(COOKIE_NAME, locale);
|
|
}
|