Vlad Chikalkin 49df4365ca
Feature/telegram integration (#4)
* add files from official template

* remove all official template trash
2024-12-11 16:00:55 +03:00

21 lines
595 B
TypeScript

// use server is required
'use server';
import { defaultLocale } from './config';
import { type Locale } from './types';
import { cookies } from 'next/headers';
// 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';
const getLocale = async () => {
return cookies().get(COOKIE_NAME)?.value || defaultLocale;
};
const setLocale = async (locale?: string) => {
cookies().set(COOKIE_NAME, (locale as Locale) || defaultLocale);
};
export { getLocale, setLocale };