Skip to main content
Glama
index.ts1.44 kB
/** * @intlayer/fetch-dictionaries-entry is a package that only returns the fetch dictionary entry file. * Using an external package allow to alias it in the bundle configuration (such as webpack). * The alias allow hot reload the app (such as nextjs) on any dictionary change. */ import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { clearModuleCache, configESMxCJSRequire } from '@intlayer/config'; import config from '@intlayer/config/built'; import type { Dictionary, DictionaryKeys, IntlayerConfig, StrictModeLocaleMap, } from '@intlayer/types'; export type FetchDictionaries = Record< DictionaryKeys, StrictModeLocaleMap<Dictionary> >; type GetFetchDictionaries = ( configuration?: IntlayerConfig ) => FetchDictionaries; export const getDynamicDictionaries: GetFetchDictionaries = ( configuration: IntlayerConfig = config ) => { const { content, build } = configuration; // Always use cjs for dictionaries entry as it uses require const dictionariesPath = join(content.mainDir, `fetch_dictionaries.cjs`); let dictionaries: Record< DictionaryKeys, StrictModeLocaleMap<Dictionary> > = {}; if (existsSync(dictionariesPath)) { // Clear cache for dynamic_dictionaries.cjs and all its dependencies (JSON files) clearModuleCache(dictionariesPath); dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath); } return dictionaries; };

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