diff --git a/js/src/common/translator-icu-rich.d.ts b/js/src/common/translator-icu-rich.d.ts new file mode 100644 index 000000000..08fb52765 --- /dev/null +++ b/js/src/common/translator-icu-rich.d.ts @@ -0,0 +1,26 @@ +declare module '@askvortsov/rich-icu-message-formatter' { + type IValues = Record; + + type ITypeHandler = ( + value: string, + matches: string, + locale: string, + values: IValues, + format: (message: string, values: IValues) => string + ) => string; + type IRichHandler = (tag: any, values: IValues, contents: string) => any; + + type ValueOrArray = T | ValueOrArray[]; + type NestedStringArray = ValueOrArray; + + export class RichMessageFormatter { + locale: string | null; + constructor(locale: string | null, typeHandlers: Record, richHandler: IRichHandler); + + format(message: string, values: IValues): string; + process(message: string, values: IValues): NestedStringArray; + rich(message: string, values: IValues): NestedStringArray; + } + + export function mithrilRichHandler(tag: any, values: IValues, contents: string): any; +} diff --git a/js/src/common/translator-icu.d.ts b/js/src/common/translator-icu.d.ts new file mode 100644 index 000000000..d1ed498f5 --- /dev/null +++ b/js/src/common/translator-icu.d.ts @@ -0,0 +1,17 @@ +declare module '@ultraq/icu-message-formatter' { + export function pluralTypeHandler( + value: string, + matches: string, + locale: string, + values: Record, + format: (text: string, values: Record) => string + ): string; + + export function selectTypeHandler( + value: string, + matches: string, + locale: string, + values: Record, + format: (text: string, values: Record) => string + ): string; +}