react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
1 lines • 910 B
Source Map (JSON)
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { DictionaryKeys, LocalesValues } from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\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 useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getIntlayer<T, L>(key, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,eACX,KACA,WACG;AAIH,QAAO,YAAkB,KAFvB,UAAU,iBAAgC,sBAAsB,CAElB"}