import { Diagnostic } from "./diagnostics.js"; export interface ConfigOptions { /** * The path of the source root directory. * @default "./src" */ src?: string; /** * The filename of the translation data file. * @default "./i18n.json" */ translationData?: string; /** * The filename template for compiled locale data. * * The `[locale]` placeholder is replaced with the locale code. * * @default "./dist/[locale]/translation.json" */ output?: string; /** * A prefix that should be used for all keys in this project. * (excluding translations from external packages) */ prefix?: string; /** * An array of locales. The first one is the locale used in source files. * @default ["en"] */ locales?: string[]; /** * A list of ignore rules. * Text content and attribute values that include interpolation are always ignored. */ ignore?: { /** Ignore elements and subtrees by tag name */ element?: ConfigOptions.IgnoreRule; /** Ignore text content */ textContent?: ConfigOptions.IgnoreRule; /** Ignore attribute values */ attributeValue?: ConfigOptions.IgnoreRule; }[]; /** * A map of elements that can be localized. * By default, nothing is localized. * * `"*"` can be used as property to match all elements. */ localize?: Record; /** * A map of elements to custom whitespace handling during extraction. * * `"*"` can be used as property to match all elements. */ whitespace?: Record; /** * Whitespace handling for node text content. */ content?: Config.WhitespaceHandling; } | Config.WhitespaceHandling>; /** * Configure how diagnostics are handled. */ diagnostics?: { [t in Diagnostic.Type | "all"]?: Config.DiagnosticHandling; }; /** * An object with locales as keys and patterns to include as external locales. * * Default is an empty object. */ externalLocales?: Record; } export declare namespace ConfigOptions { type IgnoreRule = string | RegExp | ((value: string) => boolean); } export interface Config { /** Absolute path of the project root directory */ readonly context: string; /** Absolute path of the source root directory */ readonly src: string; /** Absolute path of the translation data file */ readonly translationData: string; /** A function to get the absolute output filename for compiled locale data. */ readonly getOutputFilename: (locale: string) => string; /** A common prefix used for all keys */ readonly prefix: string; /** An array of locales. The first one is the locale used in source files. */ readonly locales: string[]; /** A function that is called to check if an element and it's sub tree should be ignored. */ ignoreElement: (tagName: string) => boolean; /** A function that is called to check text content should be ignored. */ ignoreTextContent: (content: string) => boolean; /** A function that is called to check if an attribute should be ignored. */ ignoreAttributeValue: (name: string) => boolean; /** Get the configuration how an element is localized. */ getLocalizedElement: (tagName: string) => Config.LocalizedElement | undefined; /** Get whitespace handling config for an element. */ getElementWhitespaceHandling: (tagName: string) => Config.ElementWhitespaceHandling; /** A function that is used to determine how a specific diagnostic type is handled. */ getDiagnosticHandling: (type: Diagnostic.Type) => Config.DiagnosticHandling; /** An object with locales as keys and patterns to include as external locales. */ readonly externalLocales: Record; } export declare namespace Config { enum DiagnosticHandling { Error = "error", Warning = "warn", Ignore = "ignore" } enum WhitespaceHandling { /** Extract whitespace as is. */ Preserve = "preserve", /** Trim leading and trailing whitespace. */ Trim = "trim", /** Collapse leading, trailing and whitespace in between text to a single space. */ Collapse = "collapse", /** Trim leading and trailing whitespace and collapse whitespace in betweeen text to a single space. */ TrimCollapse = "trim-collapse" } interface LocalizedElement { readonly content: ElementContentLocalizationType; readonly attributes: ReadonlySet; } interface ElementWhitespaceHandling { getAttribute: (name: string) => WhitespaceHandling; content: WhitespaceHandling; } } export declare enum ElementContentLocalizationType { None = "none", Html = "html", Text = "text" } /** * Utility for providing auto completion for js config files. */ export declare function defineConfig(options: ConfigOptions): ConfigOptions; /** * Create a configuration from simplified options. * @param context Absolute path of the project root directory. * @param options The config json data. */ export declare function createConfig(context: string, options?: ConfigOptions): Config;