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 | availableLocales: string[];
|
132 |
|
133 | |
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | defaultSeparator: string;
|
140 |
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | enableFallback: boolean;
|
152 |
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 | locale: string;
|
159 |
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | missingBehavior: MissingBehavior;
|
173 |
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 | missingPlaceholder: MissingPlaceholderHandler;
|
180 |
|
181 | |
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | nullPlaceholder: NullPlaceholderHandler;
|
188 |
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 | missingTranslationPrefix: string;
|
197 |
|
198 | |
199 |
|
200 |
|
201 |
|
202 |
|
203 | placeholder: RegExp;
|
204 |
|
205 | |
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | transformKey: (key: string) => string;
|
213 | }
|
214 |
|
215 |
|
216 | export type Scope = Readonly<string | string[]>;
|
217 |
|
218 |
|
219 | export type LocaleResolver = (i18n: I18n, locale: string) => string[];
|
220 |
|
221 |
|
222 | export type Pluralizer = (i18n: I18n, count: number) => string[];
|
223 |
|
224 |
|
225 | export type MissingTranslationStrategy = (
|
226 | i18n: I18n,
|
227 | scope: Scope,
|
228 | options: Dict,
|
229 | ) => string;
|
230 |
|
231 | export interface TranslateOptions {
|
232 | defaultValue?: any;
|
233 | count?: number;
|
234 | scope?: Scope;
|
235 | defaults?: Dict[];
|
236 | missingBehavior?: MissingBehavior | string;
|
237 | [key: string]: any;
|
238 | }
|
239 |
|
240 | export type MissingPlaceholderHandler = (
|
241 | i18n: I18n,
|
242 | placeholder: string,
|
243 | message: string,
|
244 | options: Dict,
|
245 | ) => string;
|
246 |
|
247 | export type NullPlaceholderHandler = (
|
248 | i18n: I18n,
|
249 | placeholder: string,
|
250 | message: string,
|
251 | options: Dict,
|
252 | ) => string;
|
253 |
|
254 | export type DayNames = [string, string, string, string, string, string, string];
|
255 | export type MonthNames = [
|
256 | null,
|
257 | string,
|
258 | string,
|
259 | string,
|
260 | string,
|
261 | string,
|
262 | string,
|
263 | string,
|
264 | string,
|
265 | string,
|
266 | string,
|
267 | string,
|
268 | string,
|
269 | ];
|
270 |
|
271 | export interface StrftimeOptions {
|
272 | meridian: {
|
273 | am: string;
|
274 | pm: string;
|
275 | };
|
276 |
|
277 | dayNames: DayNames;
|
278 | abbrDayNames: DayNames;
|
279 | monthNames: MonthNames;
|
280 | abbrMonthNames: MonthNames;
|
281 | }
|
282 |
|
283 | export type OnChangeHandler = (i18n: I18n) => void;
|