react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
22 lines (20 loc) • 709 B
JavaScript
import { getServerContext } from "./serverContext.mjs";
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
import configuration from "@intlayer/config/built";
//#region src/server/useLocale.ts
/**
* On the server side, Hook that picking one dictionary by its key and return the content
*
* If the locale is not provided, it will use the locale from the server context
*/
const useLocale = () => {
const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
return {
locale: getServerContext(IntlayerServerContext) ?? defaultLocale,
defaultLocale,
availableLocales
};
};
//#endregion
export { useLocale };
//# sourceMappingURL=useLocale.mjs.map