import type { UmbLocalizationSet, FunctionParams, UmbLocalizationSetBase, UmbLocalizationSetKey } from './localization.manager.js'; import type { UmbController, UmbControllerHost } from '../controller-api/index.js'; /** * The UmbLocalizationController enables localization for your element. * @see UmbLocalizeElement * @example * ```ts * import { UmbLocalizationController } from './index.js'; * * \@customElement('my-element') * export class MyElement extends LitElement { * private localize = new UmbLocalizationController(this); * * render() { * return html`

${this.localize.term('general_close')}

`; * } * } * ``` */ export declare class UmbLocalizationController implements UmbController { #private; readonly controllerAlias: symbol; constructor(host: UmbControllerHost); hostConnected(): void; hostDisconnected(): void; destroy(): void; documentUpdate(): void; keysChanged(changedKeys: Set): void; /** * Gets the host element's directionality as determined by the `dir` attribute. The return value is transformed to * lowercase. * @returns {string} - the directionality. */ dir(): string; /** * Gets the host element's language as determined by the `lang` attribute. The return value is transformed to * lowercase. * @returns {string} - the language code. */ lang(): string; /** * Outputs a translated term. * @param {string} key - the localization key, the indicator of what localization entry you want to retrieve. * @param {unknown[]} args - the arguments to parse for this localization entry. * @returns {string} - the translated term as a string. * @example * Retrieving a term without any arguments: * ```ts * this.localize.term('area_term'); * ``` * Retrieving a term with arguments: * ```ts * this.localize.term('general_greeting', ['John']); * ``` */ term(key: K, ...args: FunctionParams): string; /** * Returns the localized term for the given key, or the default value if not found. * This method follows the same resolution order as term() (primary → secondary → fallback), * but returns the provided defaultValue instead of the key when no translation is found. * @param {string} key - the localization key, the indicator of what localization entry you want to retrieve. * @param {string | null} defaultValue - the value to return if the key is not found in any localization set. * @param {unknown[]} args - the arguments to parse for this localization entry. * @returns {string | null} - the translated term or the default value. * @example * Retrieving a term with fallback: * ```ts * this.localize.termOrDefault('general_close', 'X'); * ``` * Retrieving a term with fallback and arguments: * ```ts * this.localize.termOrDefault('general_greeting', 'Hello!', userName); * ``` * Retrieving a term with null as fallback: * ```ts * this.localize.termOrDefault('general_close', null); * ``` */ termOrDefault(key: K, defaultValue: D, ...args: FunctionParams): string | D; /** * Outputs a localized date in the specified format. * @param {Date} dateToFormat - the date to format. * @param {Intl.DateTimeFormatOptions} options - the options to use when formatting the date. * @returns {string} */ date(dateToFormat: Date | string, options?: Intl.DateTimeFormatOptions): string; /** * Outputs a localized number in the specified format. * @param {number | string} numberToFormat - the number or string to format. * @param {Intl.NumberFormatOptions} options - the options to use when formatting the number. * @returns {string} - the formatted number. */ number(numberToFormat: number | string, options?: Intl.NumberFormatOptions): string; /** * Outputs a localized time in relative format. * @example "in 2 days" * @param {number} value - the value to format. * @param {Intl.RelativeTimeFormatUnit} unit - the unit of time to format. * @param {Intl.RelativeTimeFormatOptions} options - the options to use when formatting the time. * @returns {string} - the formatted time. */ relativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string; /** * Outputs a localized compounded time in a duration format. * @example "2 days, 3 hours and 5 minutes" * @param {Date} fromDate - the date to compare from. * @param {Date} toDate - the date to compare to, usually the current date (default: current date). * @param {object} options - the options to use when formatting the time. * @returns {string} - the formatted time, example: "2 days, 3 hours, 5 minutes" */ duration(fromDate: Date | string, toDate?: Date | string, options?: any): string; /** * Outputs a localized list of values in the specified format. * @example "one, two, and three" * @param {Iterable} values - the values to format. * @param {Intl.ListFormatOptions} options - the options to use when formatting the list. * @returns {string} - the formatted list. */ list(values: Iterable, options?: Intl.ListFormatOptions): string; /** * Translates a string containing one or more terms. The terms should be prefixed with a `#` character. * If the term is found in the localization set, it will be replaced with the localized term. * If the term is not found, the original term will be returned. * @param {string | undefined} text The text to translate. * @param {unknown[]} args The arguments to parse for this localization entry. * @returns {string} The translated text. */ string(text: string | undefined, ...args: unknown[]): string; }