1 | export interface Bundle<K extends string = string, D = any> {
|
2 | key: K;
|
3 | data?: D;
|
4 | }
|
5 | export interface StringBuilder<D = any> {
|
6 | (data?: D): string;
|
7 | }
|
8 | export interface StringBuilders {
|
9 | constant(str: string): StringBuilder<undefined>;
|
10 | callback<D>(callback: (data?: D) => string): StringBuilder<D>;
|
11 | messageFormat<D>(formatString: string): StringBuilder<D>;
|
12 | }
|
13 | export declare type Definition<T> = {
|
14 | [P in keyof T]: StringBuilder<T[P]>;
|
15 | };
|
16 | export interface Locale<T> {
|
17 | locale: string;
|
18 | definition: (builders: StringBuilders) => Definition<T>;
|
19 | }
|
20 | export declare function buildLocale<T>(locale: string, definition: (stringBuilders: StringBuilders) => Definition<T>): Locale<T>;
|
21 | export declare type Keys<T> = {
|
22 | [P in keyof T]: P;
|
23 | };
|
24 | export interface Bundler<T> {
|
25 | <K extends keyof T>(key: K, data?: T[K]): Bundle<K, T[K]>;
|
26 | }
|
27 | export interface Formatter<T> {
|
28 | <K extends keyof T>(key: K, data?: T[K]): string;
|
29 | <K extends keyof T>(bundle: Bundle<K, T[K]>): string;
|
30 | }
|
31 | export interface Internationalization<T> {
|
32 | keys: Keys<T>;
|
33 | bundle: Bundler<T>;
|
34 | buildFormatter(locale: string): Formatter<T>;
|
35 | }
|
36 | export declare function internationalize<T>(main: Locale<T>, ...alts: Locale<Partial<T>>[]): Internationalization<T>;
|