Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import { cookies, headers } from "next/headers";
import { translate } from ".";
import { LOCALE_COOKIE, resolveLocale } from "./locales";
export async function getRequestLocale() {
const [cookieStore, headerList] = await Promise.all([cookies(), headers()]);
return resolveLocale(cookieStore.get(LOCALE_COOKIE)?.value, headerList.get("accept-language"));
}
export async function getServerTranslator() {
const locale = await getRequestLocale();
return (source: string, params?: Record<string, string | number>) =>
translate(source, locale, params);
}
|