intl-t
Version:
A Fully-Typed Node-Based i18n Translation Library
17 lines (16 loc) • 461 B
JavaScript
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;
}