1 | import { BigNumber } from "bignumber.js";
|
2 |
|
3 | import { I18n } from "./I18n";
|
4 |
|
5 | export type MakePlural = (count: number, ordinal?: boolean) => string;
|
6 |
|
7 | export interface Dict {
|
8 | [key: string]: any;
|
9 | }
|
10 |
|
11 | export type DateTime = string | number | Date;
|
12 |
|
13 | export interface TimeAgoInWordsOptions {
|
14 | includeSeconds?: boolean;
|
15 | scope?: Scope;
|
16 | }
|
17 |
|
18 | export type Numeric = BigNumber | string | number;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export type RoundingMode =
|
38 | | "up"
|
39 | | "down"
|
40 | | "truncate"
|
41 | | "halfUp"
|
42 | | "default"
|
43 | | "halfDown"
|
44 | | "halfEven"
|
45 | | "banker"
|
46 | | "ceiling"
|
47 | | "ceil"
|
48 | | "floor";
|
49 |
|
50 | export interface FormatNumberOptions {
|
51 | format: string;
|
52 | negativeFormat: string;
|
53 | precision: number | null;
|
54 | roundMode: RoundingMode;
|
55 | significant: boolean;
|
56 | separator: string;
|
57 | delimiter: string;
|
58 | stripInsignificantZeros: boolean;
|
59 | raise: boolean;
|
60 | unit: string;
|
61 | }
|
62 |
|
63 |
|
64 | export type NumberToHumanSizeOptions = Omit<
|
65 | FormatNumberOptions,
|
66 | "format" | "negativeFormat" | "raise"
|
67 | >;
|
68 |
|
69 | export type NumberToHumanUnits = {
|
70 | [key: string]: string;
|
71 | };
|
72 |
|
73 | export type NumberToHumanOptions = Omit<
|
74 | FormatNumberOptions,
|
75 | "negativeFormat" | "unit" | "raise"
|
76 | > & {
|
77 | units: NumberToHumanUnits | string;
|
78 | };
|
79 |
|
80 | export type NumberToDelimitedOptions = {
|
81 | delimiterPattern: RegExp;
|
82 | delimiter: string;
|
83 | separator: string;
|
84 | };
|
85 |
|
86 | export type NumberToPercentageOptions = Omit<FormatNumberOptions, "raise">;
|
87 |
|
88 | export type NumberToRoundedOptions = Omit<
|
89 | FormatNumberOptions,
|
90 | "format" | "negativeFormat" | "raise"
|
91 | > & { precision: number };
|
92 |
|
93 | export type NumberToCurrencyOptions = FormatNumberOptions;
|
94 |
|
95 | export interface ToSentenceOptions {
|
96 | wordsConnector: string;
|
97 | twoWordsConnector: string;
|
98 | lastWordConnector: string;
|
99 | }
|
100 |
|
101 |
|
102 | export type PrimitiveType = number | string | null | undefined | boolean;
|
103 | export type ArrayType = AnyObject[];
|
104 | export type AnyObject = PrimitiveType | ArrayType | ObjectType;
|
105 |
|
106 | export interface ObjectType {
|
107 | [key: string]: PrimitiveType | ArrayType | ObjectType;
|
108 | }
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | export type MissingBehavior = "message" | "guess" | "error";
|
115 |
|
116 |
|
117 | export interface I18nOptions {
|
118 | |
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 | defaultLocale: string;
|
125 |
|
126 | |
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | defaultSeparator: string;
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | enableFallback: boolean;
|
145 |
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 | locale: string;
|
152 |
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 | missingBehavior: MissingBehavior;
|
166 |
|
167 | |
168 |
|
169 |
|
170 |
|
171 |
|
172 | missingPlaceholder: MissingPlaceholderHandler;
|
173 |
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | nullPlaceholder: NullPlaceholderHandler;
|
181 |
|
182 | |
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | missingTranslationPrefix: string;
|
190 |
|
191 | |
192 |
|
193 |
|
194 |
|
195 |
|
196 | placeholder: RegExp;
|
197 |
|
198 | |
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 | transformKey: (key: string) => string;
|
206 | }
|
207 |
|
208 |
|
209 | export type Scope = Readonly<string | string[]>;
|
210 |
|
211 |
|
212 | export type LocaleResolver = (i18n: I18n, locale: string) => string[];
|
213 |
|
214 |
|
215 | export type Pluralizer = (i18n: I18n, count: number) => string[];
|
216 |
|
217 |
|
218 | export type MissingTranslationStrategy = (
|
219 | i18n: I18n,
|
220 | scope: Scope,
|
221 | options: Dict,
|
222 | ) => string;
|
223 |
|
224 | export interface TranslateOptions {
|
225 | defaultValue?: any;
|
226 | count?: number;
|
227 | scope?: Scope;
|
228 | defaults?: Dict[];
|
229 | missingBehavior?: MissingBehavior | string;
|
230 | [key: string]: any;
|
231 | }
|
232 |
|
233 | export type MissingPlaceholderHandler = (
|
234 | i18n: I18n,
|
235 | placeholder: string,
|
236 | message: string,
|
237 | options: Dict,
|
238 | ) => string;
|
239 |
|
240 | export type NullPlaceholderHandler = (
|
241 | i18n: I18n,
|
242 | placeholder: string,
|
243 | message: string,
|
244 | options: Dict,
|
245 | ) => string;
|
246 |
|
247 | export type DayNames = [string, string, string, string, string, string, string];
|
248 | export type MonthNames = [
|
249 | null,
|
250 | string,
|
251 | string,
|
252 | string,
|
253 | string,
|
254 | string,
|
255 | string,
|
256 | string,
|
257 | string,
|
258 | string,
|
259 | string,
|
260 | string,
|
261 | string,
|
262 | ];
|
263 |
|
264 | export interface StrftimeOptions {
|
265 | meridian: {
|
266 | am: string;
|
267 | pm: string;
|
268 | };
|
269 |
|
270 | dayNames: DayNames;
|
271 | abbrDayNames: DayNames;
|
272 | monthNames: MonthNames;
|
273 | abbrMonthNames: MonthNames;
|
274 |
|
275 |
|
276 | utc?: boolean;
|
277 | }
|
278 |
|
279 | export type OnChangeHandler = (i18n: I18n) => void;
|