mirror of
https://github.com/flarum/core.git
synced 2025-07-31 21:50:50 +02:00
Add typing files for our translator libraries (#3175)
This commit is contained in:
committed by
GitHub
parent
94370375a5
commit
71cb8c378f
26
js/src/common/translator-icu-rich.d.ts
vendored
Normal file
26
js/src/common/translator-icu-rich.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
declare module '@askvortsov/rich-icu-message-formatter' {
|
||||||
|
type IValues = Record<string, any>;
|
||||||
|
|
||||||
|
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> = T | ValueOrArray<T>[];
|
||||||
|
type NestedStringArray = ValueOrArray<string>;
|
||||||
|
|
||||||
|
export class RichMessageFormatter {
|
||||||
|
locale: string | null;
|
||||||
|
constructor(locale: string | null, typeHandlers: Record<string, ITypeHandler>, 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;
|
||||||
|
}
|
17
js/src/common/translator-icu.d.ts
vendored
Normal file
17
js/src/common/translator-icu.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
declare module '@ultraq/icu-message-formatter' {
|
||||||
|
export function pluralTypeHandler(
|
||||||
|
value: string,
|
||||||
|
matches: string,
|
||||||
|
locale: string,
|
||||||
|
values: Record<string, any>,
|
||||||
|
format: (text: string, values: Record<string, any>) => string
|
||||||
|
): string;
|
||||||
|
|
||||||
|
export function selectTypeHandler(
|
||||||
|
value: string,
|
||||||
|
matches: string,
|
||||||
|
locale: string,
|
||||||
|
values: Record<string, any>,
|
||||||
|
format: (text: string, values: Record<string, any>) => string
|
||||||
|
): string;
|
||||||
|
}
|
Reference in New Issue
Block a user