react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
1 lines • 1.04 kB
Source Map (JSON)
{"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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAE1B,oCAAsC;AACtC,2BAAiC;AAO1B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,cAAc,IAAI,aAAAA,SAAe,wBAAwB,CAAC;AAClE,QAAM,aACH,uCAAgC,mDAAqB,KACrD;AAEH,SAAO,EAAE,OAAO;AAClB;","names":["configuration"]}