react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
20 lines (17 loc) • 615 B
JavaScript
'use client';
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
import { useContext } from "react";
import { getTranslation } from "@intlayer/core";
//#region src/client/t.ts
/**
* On the client side, this function returns the translation of the provided multilang content.
*
* If the locale is not provided, it will use the locale from the client context
*/
const t = (multilangContent, locale) => {
const { locale: currentLocale } = useContext(IntlayerClientContext);
return getTranslation(multilangContent, locale ?? currentLocale);
};
//#endregion
export { t };
//# sourceMappingURL=t.mjs.map