2021-11-27 06:30:49 +08:00
|
|
|
/// <reference path="../../src/common/translator-icu-rich.d.ts" />
|
|
|
|
import { RichMessageFormatter } from '@askvortsov/rich-icu-message-formatter';
|
|
|
|
import { pluralTypeHandler, selectTypeHandler } from '@ultraq/icu-message-formatter';
|
2021-05-13 07:29:46 +08:00
|
|
|
declare type Translations = Record<string, string>;
|
|
|
|
declare type TranslatorParameters = Record<string, unknown>;
|
|
|
|
export default class Translator {
|
|
|
|
/**
|
|
|
|
* A map of translation keys to their translated values.
|
|
|
|
*/
|
|
|
|
translations: Translations;
|
|
|
|
/**
|
|
|
|
* The underlying ICU MessageFormatter util.
|
|
|
|
*/
|
2021-11-27 06:30:49 +08:00
|
|
|
protected formatter: RichMessageFormatter;
|
2021-05-13 07:29:46 +08:00
|
|
|
setLocale(locale: string): void;
|
|
|
|
addTranslations(translations: Translations): void;
|
|
|
|
/**
|
|
|
|
* An extensible entrypoint for extenders to register type handlers for translations.
|
|
|
|
*/
|
|
|
|
protected formatterTypeHandlers(): {
|
2021-11-27 06:30:49 +08:00
|
|
|
plural: typeof pluralTypeHandler;
|
|
|
|
select: typeof selectTypeHandler;
|
2021-05-13 07:29:46 +08:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* A temporary system to preprocess parameters.
|
|
|
|
* Should not be used by extensions.
|
|
|
|
* TODO: An extender will be added in v1.x.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
protected preprocessParameters(parameters: TranslatorParameters): TranslatorParameters;
|
2021-11-27 06:30:49 +08:00
|
|
|
trans(id: string, parameters?: TranslatorParameters): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
|
2021-05-13 07:29:46 +08:00
|
|
|
}
|
|
|
|
export {};
|