mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-19 16:59:45 +02:00
locale.ts erstellen
This commit is contained in:
parent
9001135f92
commit
5c823fc23f
1 changed files with 16 additions and 0 deletions
16
src/services/locale.ts
Normal file
16
src/services/locale.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
'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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue