Skip to main content
Glama
useDictionary.ts829 B
'use client'; import type { DeclaredLocales, Dictionary, LocalesValues, } from '@intlayer/types'; import { useContext, useMemo } from 'react'; import { getDictionary } from '../getDictionary'; import { IntlayerClientContext } from './IntlayerProvider'; /** * On the server side, Hook that transform a dictionary and return the content * * If the locale is not provided, it will use the locale from the client context */ export const useDictionary = < T extends Dictionary, L extends LocalesValues = DeclaredLocales, >( dictionary: T, locale?: L ) => { const { locale: currentLocale } = useContext(IntlayerClientContext); return useMemo(() => { const localeTarget = locale ?? currentLocale; return getDictionary<T, L>(dictionary, localeTarget as L); }, [dictionary, currentLocale, locale]); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server