UNPKG

react-intlayer

Version:

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

1 lines 991 B
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type DictionaryKeys } from '@intlayer/core';\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, K extends LocalesValues>(\n key: T,\n locale?: K\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":"AAEA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAAc,CACzB,KACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAEjE,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}