UNPKG

@intl-t/next

Version:

A Fully-Typed Object-Based i18n Translation Library for Next.js

17 lines (16 loc) 463 B
import { cache } from "react"; export const getCache = cache(() => ({})); export function getCachedRequestLocale() { const locale = getCache().locale; // @ts-ignore if (this?.settings) this.settings.locale = locale; return locale; } export function setCachedRequestLocale(locale) { getCache().locale = locale; // @ts-ignore if (this?.settings) ((this.settings.locale = locale), this?.t?.then?.()); return locale; }