import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter'; import type { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues, } from '@intlayer/types/module_augmentation'; import { type DeepTransformContent, getPlugins } from './plugins'; /** * Picks one dictionary by its key and returns its content for the given * locale or selector (`{ item }`, `{ variant }`, * optionally combined with `locale`). */ export const getIntlayer = < const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey = DeclaredLocales, >( key: T, localeOrSelector?: A ): DeepTransformContent< DictionaryRegistryResult, ExtractSelectorLocale > => { const locale = ( typeof localeOrSelector === 'object' && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector ) as LocalesValues | undefined; return getIntlayerCore(key, localeOrSelector, getPlugins(locale)) as any; };