import { Config } from "./config.js"; import { Diagnostics } from "./diagnostics.js"; import { LocaleData } from "./locale-data.js"; /** * A container for translation data that is used as an * interface between this library and external tools. */ export declare class TranslationData { #private; /** A map of absolute filenames to file information */ readonly files: Map; /** An array of obsolete translations */ readonly obsolete: TranslationData.ObsoleteTranslation[]; /** The version of the file that was loaded */ readonly parsedVersion: 1 | 2; constructor( /** A map of absolute filenames to file information */ files?: Map, /** An array of obsolete translations */ obsolete?: TranslationData.ObsoleteTranslation[], /** The version of the file that was loaded */ parsedVersion?: 1 | 2); /** * Update extracted keys and delete missing ones. * @param filename The filename. * @param keys A map of i18n keys to english translations. * @returns true if anything has been modified. */ updateKeys(filename: string, keys: Map): boolean; /** * Compile all included locales. * @param config The project configuration. * @returns A map of locale ids to compiled locale data. */ compile(config: Config, diagnostics: Diagnostics): Map; /** * Replace a key and keep all the translations. * @param filename The filename. * @param oldKey The key to replace. * @param newKey The new key. * @param hintFilenames A hint to other files where translations for the old key could be found. * @returns true if anything has been copied. */ copyTranslations(filename: string, oldKey: string, newKey: string, hintFilenames?: Iterable): boolean; deleteFile(filename: string): void; /** * Deep clone a translation set. * @param value The set to clone. * @param markAsOutdated If true, the clone will be marked as outdated. Default is `true` */ static cloneTranslationSet(value: TranslationData.TranslationSet, markAsOutdated?: boolean): TranslationData.TranslationSet; /** * Deep clone a translation object. */ static cloneTranslation(value: TranslationData.Translation): TranslationData.Translation; /** * Validate and add json data. * @param json The json data. * @param basePath The base path for resolving filenames. */ static parse(json: string, basePath: string): TranslationData; /** * Format this translation data as json. * @param basePath The base path for creating relative filenames. */ formatJson(basePath: string): string; } export declare namespace TranslationData { /** Represents a source file. */ interface File { /** The key translation pairs that are extracted from the file. */ readonly content: Map; } /** Represents an extracted translation with additional translations. */ interface TranslationSet { /** The translation from the source file. */ source: Translation; /** A map of locale ids to additional translations. */ readonly translations: Map; } /** Represents a translation value. */ interface Translation { /** The content. */ content: string; /** The last time this value was modified. */ lastModified: number; /** An array of strings that are ignored by spell checkers. */ ignoreSpelling: string[]; } interface ObsoleteTranslation { /** The content. */ content: string; /** A map of locale ids to translated content. */ readonly translations: Map; } function isJsonV2(data: JsonV1 | JsonV2): data is JsonV2; /** * Type for the json schema of serialized translation data. */ interface JsonV2 { version: 2; files: Record; obsolete: JsonV2.ObsoleteTranslation[]; } type JsonV1 = Record; namespace JsonV2 { interface File { content: Record; } interface TranslationSet extends Translation { translations: Record; } interface Translation { content: string; lastModified: string; ignoreSpelling: string[]; } interface ObsoleteTranslation { content: string; translations: Record; } } }