Skip to main content
Glama
formatDictionary.ts1.74 kB
import { i18nextToIntlayerFormatter, icuToIntlayerFormatter, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToVueI18nFormatter, vueI18nToIntlayerFormatter, } from '@intlayer/core/messageFormat'; import type { Dictionary } from '@intlayer/types'; export const formatDictionary = (dictionary: Dictionary): Dictionary => { if (dictionary.format === 'icu') { return { ...dictionary, format: 'intlayer', content: icuToIntlayerFormatter(dictionary.content), }; } if (dictionary.format === 'i18next') { return { ...dictionary, format: 'intlayer', content: i18nextToIntlayerFormatter(dictionary.content), }; } if (dictionary.format === 'vue-i18n') { return { ...dictionary, format: 'intlayer', content: vueI18nToIntlayerFormatter(dictionary.content), }; } return dictionary; }; export const formatDictionaries = (dictionaries: Dictionary[]): Dictionary[] => dictionaries.map(formatDictionary); export const formatDictionaryOutput = (dictionary: Dictionary) => { if (dictionary.format === 'icu') { return { ...dictionary, format: 'icu', content: intlayerToICUFormatter(dictionary.content), }; } if (dictionary.format === 'i18next') { return { ...dictionary, format: 'i18next', content: intlayerToI18nextFormatter(dictionary.content), }; } if (dictionary.format === 'vue-i18n') { return { ...dictionary, format: 'vue-i18n', content: intlayerToVueI18nFormatter(dictionary.content), }; } return dictionary; }; export const formatDictionariesOutput = (dictionaries: Dictionary[]) => dictionaries.map(formatDictionaryOutput);

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