UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

1 lines 981 B
{"version":3,"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = () => {\n const { defaultLocale } = configuration?.internationalization ?? {};\n const locale =\n (getServerContext<LocalesValues>(IntlayerServerContext) as Locales) ??\n (defaultLocale as Locales);\n\n return { locale };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,cAAc,IAAI,eAAe,wBAAwB,CAAC;AAClE,QAAM,SACH,iBAAgC,qBAAqB,KACrD;AAEH,SAAO,EAAE,OAAO;AAClB;","names":[]}