Skip to main content
Glama
useDictionary.ts817 B
import { computed, inject } from '@angular/core'; import type { Dictionary, LocalesValues } from '@intlayer/types'; import { getDictionary } from '../getDictionary'; import type { DeepTransformContent } from '../plugins'; import { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer'; export const useDictionary = <T extends Dictionary>( dictionary: T, locale?: LocalesValues ): DeepTransformContent<T['content']> => { const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN); const localeTarget = computed(() => locale ?? intlayer?.locale()); /** a *stable* reactive dictionary object */ const content = computed(() => getDictionary<T, LocalesValues>(dictionary, localeTarget()) ); return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity };

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