UNPKG

940 BTypeScriptView Raw
1declare namespace MessageFormat {
2 type Msg = { (params: {}): string; toString(global?: string): string };
3 type Formatter = (val: any, lc: string, arg?: string) => string;
4 type SrcMessage = string | SrcObject;
5
6 interface SrcObject {
7 [key: string]: SrcMessage;
8 }
9
10 interface Options {
11 biDiSupport?: boolean;
12 customFormatters?: { [name: string]: Formatter };
13 pluralKeyChecks?: boolean;
14 strictNumberSign?: boolean;
15 }
16}
17
18declare class MessageFormat {
19 constructor(
20 locales?: { [locale: string]: Function } | string[] | string,
21 options?: MessageFormat.Options
22 );
23 addFormatters: (format: { [name: string]: MessageFormat.Formatter }) => this;
24 disablePluralKeyChecks: () => this;
25 setBiDiSupport: (enable: boolean) => this;
26 setStrictNumberSign: (enable: boolean) => this;
27 compile: (
28 messages: MessageFormat.SrcMessage,
29 locale?: string
30 ) => MessageFormat.Msg;
31}
32
33export = MessageFormat;