react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
1 lines • 1.62 kB
Source Map (JSON)
{"version":3,"file":"IntlayerServerProvider.cjs","names":["configuration","createServerContext","getServerContext","IntlayerServerProvider: FC<IntlayerServerProviderProps>","locale"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;;AAMA,MAAM,EAAE,kBAAkBA,gCAAe,wBAAwB,EAAE;;;;AAKnE,MAAa,wBACXC,iDAAmC,cAAc;;;;AAKnD,MAAa,oBAAoBC,8CAAiB,sBAAsB;;;;AAKxE,MAAa,SAASA,8CAAiB,sBAAsB;;;;AAS7D,MAAaC,0BAA2D,EACtE,UACA,mBAAS,oBAET,2CAAC,sBAAsB;CAAS,OAAOC;CACpC;EAC8B"}