Skip to main content
Glama
loadLocalDictionaries.ts1.17 kB
import { mkdir } from 'node:fs/promises'; import { relative, resolve } from 'node:path'; import type { Dictionary, IntlayerConfig } from '@intlayer/types'; import { loadContentDeclarations } from './loadContentDeclaration'; export const loadLocalDictionaries = async ( contentDeclarationsPaths: string[] | string, configuration: IntlayerConfig ): Promise<Dictionary[]> => { const { content } = configuration; const { dictionariesDir, baseDir } = content; if (typeof contentDeclarationsPaths === 'string') { contentDeclarationsPaths = [contentDeclarationsPaths]; } // Create the dictionaries folder if it doesn't exist await mkdir(resolve(dictionariesDir), { recursive: true }); const result: Dictionary[] = []; for await (const contentDeclarationPath of contentDeclarationsPaths) { const dictionary = await loadContentDeclarations( [contentDeclarationPath], configuration ); const relativeFilePath = relative(baseDir, contentDeclarationPath); const dictionaryWithPath: Dictionary = { ...dictionary[0], filePath: relativeFilePath, }; result.push(dictionaryWithPath); } return result; };

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