@juit/vue-i18n 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,705 @@
1
+ import { App } from 'vue';
2
+
3
+ /** Base translations, either required when languages are set or all optional */
4
+ declare type BaseTranslation = ISOLanguage extends Language ? {
5
+ readonly [key in ISOLanguage]?: string;
6
+ } : {
7
+ readonly [key in Language]: string;
8
+ };
9
+
10
+ /**
11
+ * The date input type for date and time translation
12
+ *
13
+ * When the input is a non-empty `string`, or a `number`, it will be constructed
14
+ * into a `Date` object before being formatted.
15
+ *
16
+ * When the input is `null`, `undefined`, or an empty string, formatted result
17
+ * will be a simple empty string.
18
+ */
19
+ export declare type DateInput = Date | string | number | null | undefined;
20
+
21
+ /**
22
+ * Options to initialize the date and time formats used by the translation
23
+ * system.
24
+ *
25
+ * * `dateTimeFormat`: the default format for times and dates used by `$d(...)`.
26
+ * * `dateOnlyFormat`: the default format for dates used by `$d.date(...)`.
27
+ * * `timeOnlyFormat`: the default format for times used by `$d.time(...)`.
28
+ * * `numberFormat`: the default format for numbers used by `$n(...)`.
29
+ */
30
+ export declare interface DateTimeFormats {
31
+ dateOnlyFormat?: Intl.DateTimeFormatOptions | Intl.DateTimeFormatOptions['dateStyle'];
32
+ timeOnlyFormat?: Intl.DateTimeFormatOptions | Intl.DateTimeFormatOptions['timeStyle'];
33
+ dateTimeFormat?: Intl.DateTimeFormatOptions | (Intl.DateTimeFormatOptions['dateStyle'] & Intl.DateTimeFormatOptions['timeStyle']);
34
+ numberFormat?: Intl.NumberFormatOptions;
35
+ }
36
+
37
+ /** The language or locale to use at construction */
38
+ export declare type DefaultLanguage = ISOLanguage | `${ISOLanguage}-${string}` | Intl.Locale;
39
+
40
+ /** Extended translations, supporting multiple region of each language */
41
+ declare type ExtendedTranslation = {
42
+ readonly [key in `${Language}-${string}`]?: string;
43
+ };
44
+
45
+ /** Extract the value associated with key `K` from type `T` if it extends `R`, otherwise return `R` */
46
+ declare type ExtractConfig<T, R, K extends string> = T extends {
47
+ [X in K]: infer V;
48
+ } ? V extends R ? V : R : R;
49
+
50
+ /** Initialize the translation system plugin */
51
+ export declare function i18n(app: App, optionsOrLanguage: Language | I18nOptions): App;
52
+
53
+ /**
54
+ * I18n Configuration interface (to be merged with the actual configuration).
55
+ *
56
+ * This interface (intentionally empty) is used to merge the actual per-app
57
+ * configuration of the translation system, in order to provide the correct
58
+ * types to the rest of the system.
59
+ *
60
+ * Two properties are expected to be defined in the configuration:
61
+ *
62
+ * * `languages`: the list of supported languages for the application. Those
63
+ * are ISO 639-1 language codes, and when specified, _every_
64
+ * translation _must_ include a translation for each.
65
+ * * `translationKeys`: the list of translation keys known by the application.
66
+ * Those are the arbitrary keys used to identify the
67
+ * messages to be translated with the `t` and `tc`
68
+ * methods of `Translator`.
69
+ *
70
+ * To configure the types, follow the example below:
71
+ *
72
+ * ```ts
73
+ * const translations = {
74
+ * 'hello': { en: 'Hello, world!', de: 'Hallo, Welt!' }
75
+ * } as const satisfies TranslationsOptions
76
+ *
77
+ * declare module '@juit/vue-i18n' {
78
+ * export interface I18nConfiguration {
79
+ * translationKeys: keyof typeof translations
80
+ * languages: 'de' | 'en'
81
+ * }
82
+ * }
83
+ * ```
84
+ */
85
+ export declare interface I18nConfiguration {
86
+ }
87
+
88
+ /** Options to initialize the I18n plugin */
89
+ export declare interface I18nOptions {
90
+ defaultLanguage: DefaultLanguage;
91
+ translations?: Translations;
92
+ formats?: DateTimeFormats;
93
+ }
94
+
95
+ /** Array of all known ISO-3166-1 countries */
96
+ export declare type IsoCountries = {
97
+ AD: 'Andorra';
98
+ AE: 'United Arab Emirates';
99
+ AF: 'Afghanistan';
100
+ AG: 'Antigua & Barbuda';
101
+ AI: 'Anguilla';
102
+ AL: 'Albania';
103
+ AM: 'Armenia';
104
+ AO: 'Angola';
105
+ AQ: 'Antarctica';
106
+ AR: 'Argentina';
107
+ AS: 'American Samoa';
108
+ AT: 'Austria';
109
+ AU: 'Australia';
110
+ AW: 'Aruba';
111
+ AX: 'Åland Islands';
112
+ AZ: 'Azerbaijan';
113
+ BA: 'Bosnia & Herzegovina';
114
+ BB: 'Barbados';
115
+ BD: 'Bangladesh';
116
+ BE: 'Belgium';
117
+ BF: 'Burkina Faso';
118
+ BG: 'Bulgaria';
119
+ BH: 'Bahrain';
120
+ BI: 'Burundi';
121
+ BJ: 'Benin';
122
+ BL: 'St. Barthélemy';
123
+ BM: 'Bermuda';
124
+ BN: 'Brunei';
125
+ BO: 'Bolivia';
126
+ BQ: 'Caribbean Netherlands';
127
+ BR: 'Brazil';
128
+ BS: 'Bahamas';
129
+ BT: 'Bhutan';
130
+ BV: 'Bouvet Island';
131
+ BW: 'Botswana';
132
+ BY: 'Belarus';
133
+ BZ: 'Belize';
134
+ CA: 'Canada';
135
+ CC: 'Cocos (Keeling) Islands';
136
+ CF: 'Central African Republic';
137
+ CG: 'Congo - Brazzaville';
138
+ CH: 'Switzerland';
139
+ CI: 'Côte d\'Ivoire';
140
+ CK: 'Cook Islands';
141
+ CL: 'Chile';
142
+ CM: 'Cameroon';
143
+ CN: 'China';
144
+ CO: 'Colombia';
145
+ CR: 'Costa Rica';
146
+ CU: 'Cuba';
147
+ CV: 'Cape Verde';
148
+ CW: 'Curaçao';
149
+ CX: 'Christmas Island';
150
+ CY: 'Cyprus';
151
+ CZ: 'Czechia';
152
+ DE: 'Germany';
153
+ DJ: 'Djibouti';
154
+ DK: 'Denmark';
155
+ DM: 'Dominica';
156
+ DO: 'Dominican Republic';
157
+ DZ: 'Algeria';
158
+ EC: 'Ecuador';
159
+ EE: 'Estonia';
160
+ EG: 'Egypt';
161
+ EH: 'Western Sahara';
162
+ ER: 'Eritrea';
163
+ ES: 'Spain';
164
+ ET: 'Ethiopia';
165
+ FI: 'Finland';
166
+ FJ: 'Fiji';
167
+ FK: 'Falkland Islands';
168
+ FM: 'Micronesia';
169
+ FO: 'Faroe Islands';
170
+ FR: 'France';
171
+ GA: 'Gabon';
172
+ GB: 'United Kingdom';
173
+ GD: 'Grenada';
174
+ GE: 'Georgia';
175
+ GF: 'French Guiana';
176
+ GG: 'Guernsey';
177
+ GH: 'Ghana';
178
+ GI: 'Gibraltar';
179
+ GL: 'Greenland';
180
+ GM: 'Gambia';
181
+ GN: 'Guinea';
182
+ GP: 'Guadeloupe';
183
+ GQ: 'Equatorial Guinea';
184
+ GR: 'Greece';
185
+ GS: 'South Georgia & South Sandwich Islands';
186
+ GT: 'Guatemala';
187
+ GU: 'Guam';
188
+ GW: 'Guinea-Bissau';
189
+ GY: 'Guyana';
190
+ HK: 'Hong Kong SAR China';
191
+ HM: 'Heard & McDonald Islands';
192
+ HN: 'Honduras';
193
+ HR: 'Croatia';
194
+ HT: 'Haiti';
195
+ HU: 'Hungary';
196
+ ID: 'Indonesia';
197
+ IE: 'Ireland';
198
+ IL: 'Israel';
199
+ IM: 'Isle of Man';
200
+ IN: 'India';
201
+ IO: 'British Indian Ocean Territory';
202
+ IQ: 'Iraq';
203
+ IR: 'Iran';
204
+ IS: 'Iceland';
205
+ IT: 'Italy';
206
+ JE: 'Jersey';
207
+ JM: 'Jamaica';
208
+ JO: 'Jordan';
209
+ JP: 'Japan';
210
+ KE: 'Kenya';
211
+ KG: 'Kyrgyzstan';
212
+ KH: 'Cambodia';
213
+ KI: 'Kiribati';
214
+ KM: 'Comoros';
215
+ KN: 'St. Kitts & Nevis';
216
+ KP: 'North Korea';
217
+ KR: 'South Korea';
218
+ KW: 'Kuwait';
219
+ KY: 'Cayman Islands';
220
+ KZ: 'Kazakhstan';
221
+ LA: 'Laos';
222
+ LB: 'Lebanon';
223
+ LC: 'St. Lucia';
224
+ LI: 'Liechtenstein';
225
+ LK: 'Sri Lanka';
226
+ LR: 'Liberia';
227
+ LS: 'Lesotho';
228
+ LT: 'Lithuania';
229
+ LU: 'Luxembourg';
230
+ LV: 'Latvia';
231
+ LY: 'Libya';
232
+ MA: 'Morocco';
233
+ MC: 'Monaco';
234
+ MD: 'Moldova';
235
+ ME: 'Montenegro';
236
+ MF: 'St. Martin';
237
+ MG: 'Madagascar';
238
+ MH: 'Marshall Islands';
239
+ MK: 'North Macedonia';
240
+ ML: 'Mali';
241
+ MM: 'Myanmar (Burma)';
242
+ MN: 'Mongolia';
243
+ MO: 'Macao SAR China';
244
+ MP: 'Northern Mariana Islands';
245
+ MQ: 'Martinique';
246
+ MR: 'Mauritania';
247
+ MS: 'Montserrat';
248
+ MT: 'Malta';
249
+ MU: 'Mauritius';
250
+ MV: 'Maldives';
251
+ MW: 'Malawi';
252
+ MX: 'Mexico';
253
+ MY: 'Malaysia';
254
+ MZ: 'Mozambique';
255
+ NA: 'Namibia';
256
+ NC: 'New Caledonia';
257
+ NE: 'Niger';
258
+ NF: 'Norfolk Island';
259
+ NG: 'Nigeria';
260
+ NI: 'Nicaragua';
261
+ NL: 'Netherlands';
262
+ NO: 'Norway';
263
+ NP: 'Nepal';
264
+ NR: 'Nauru';
265
+ NU: 'Niue';
266
+ NZ: 'New Zealand';
267
+ OM: 'Oman';
268
+ PA: 'Panama';
269
+ PE: 'Peru';
270
+ PF: 'French Polynesia';
271
+ PG: 'Papua New Guinea';
272
+ PH: 'Philippines';
273
+ PK: 'Pakistan';
274
+ PL: 'Poland';
275
+ PM: 'St. Pierre & Miquelon';
276
+ PN: 'Pitcairn Islands';
277
+ PR: 'Puerto Rico';
278
+ PS: 'Palestinian Territories';
279
+ PT: 'Portugal';
280
+ PW: 'Palau';
281
+ PY: 'Paraguay';
282
+ QA: 'Qatar';
283
+ RE: 'Réunion';
284
+ RO: 'Romania';
285
+ RS: 'Serbia';
286
+ RU: 'Russia';
287
+ RW: 'Rwanda';
288
+ SA: 'Saudi Arabia';
289
+ SB: 'Solomon Islands';
290
+ SC: 'Seychelles';
291
+ SD: 'Sudan';
292
+ SE: 'Sweden';
293
+ SG: 'Singapore';
294
+ SH: 'St. Helena';
295
+ SI: 'Slovenia';
296
+ SJ: 'Svalbard & Jan Mayen';
297
+ SK: 'Slovakia';
298
+ SL: 'Sierra Leone';
299
+ SM: 'San Marino';
300
+ SN: 'Senegal';
301
+ SO: 'Somalia';
302
+ SR: 'Suriname';
303
+ SS: 'South Sudan';
304
+ ST: 'São Tomé & Príncipe';
305
+ SV: 'El Salvador';
306
+ SX: 'Sint Maarten';
307
+ SY: 'Syria';
308
+ SZ: 'Eswatini';
309
+ TC: 'Turks & Caicos Islands';
310
+ TD: 'Chad';
311
+ TF: 'French Southern Territories';
312
+ TG: 'Togo';
313
+ TH: 'Thailand';
314
+ TJ: 'Tajikistan';
315
+ TK: 'Tokelau';
316
+ TL: 'Timor-Leste';
317
+ TM: 'Turkmenistan';
318
+ TN: 'Tunisia';
319
+ TO: 'Tonga';
320
+ TR: 'Türkiye';
321
+ TT: 'Trinidad & Tobago';
322
+ TV: 'Tuvalu';
323
+ TW: 'Taiwan';
324
+ TZ: 'Tanzania';
325
+ UA: 'Ukraine';
326
+ UG: 'Uganda';
327
+ UM: 'U.S. Outlying Islands';
328
+ US: 'United States';
329
+ UY: 'Uruguay';
330
+ UZ: 'Uzbekistan';
331
+ VA: 'Vatican City';
332
+ VC: 'St. Vincent & Grenadines';
333
+ VE: 'Venezuela';
334
+ VG: 'British Virgin Islands';
335
+ VI: 'U.S. Virgin Islands';
336
+ VN: 'Vietnam';
337
+ VU: 'Vanuatu';
338
+ WF: 'Wallis & Futuna';
339
+ WS: 'Samoa';
340
+ YE: 'Yemen';
341
+ YT: 'Mayotte';
342
+ ZA: 'South Africa';
343
+ ZM: 'Zambia';
344
+ ZW: 'Zimbabwe';
345
+ };
346
+
347
+ /** Array of all known ISO-3166-1 countries */
348
+ export declare type ISOCountry = keyof IsoCountries;
349
+
350
+ /** All known ISO-639-1 languages */
351
+ export declare type ISOLanguage = keyof IsoLanguages;
352
+
353
+ /** Array of all known ISO-639-1 languages */
354
+ export declare type IsoLanguages = {
355
+ aa: 'Afar';
356
+ ab: 'Abkhazian';
357
+ ae: 'Avestan';
358
+ af: 'Afrikaans';
359
+ ak: 'Akan';
360
+ am: 'Amharic';
361
+ an: 'Aragonese';
362
+ ar: 'Arabic';
363
+ as: 'Assamese';
364
+ av: 'Avaric';
365
+ ay: 'Aymara';
366
+ az: 'Azerbaijani';
367
+ ba: 'Bashkir';
368
+ be: 'Belarusian';
369
+ bg: 'Bulgarian';
370
+ bh: 'Bhojpuri';
371
+ bi: 'Bislama';
372
+ bm: 'Bambara';
373
+ bn: 'Bangla';
374
+ bo: 'Tibetan';
375
+ br: 'Breton';
376
+ bs: 'Bosnian';
377
+ ca: 'Catalan';
378
+ ce: 'Chechen';
379
+ ch: 'Chamorro';
380
+ co: 'Corsican';
381
+ cr: 'Cree';
382
+ cs: 'Czech';
383
+ cu: 'Church Slavic';
384
+ cv: 'Chuvash';
385
+ cy: 'Welsh';
386
+ da: 'Danish';
387
+ de: 'German';
388
+ dv: 'Divehi';
389
+ dz: 'Dzongkha';
390
+ ee: 'Ewe';
391
+ el: 'Greek';
392
+ en: 'English';
393
+ eo: 'Esperanto';
394
+ es: 'Spanish';
395
+ et: 'Estonian';
396
+ eu: 'Basque';
397
+ fa: 'Persian';
398
+ ff: 'Fula';
399
+ fi: 'Finnish';
400
+ fj: 'Fijian';
401
+ fo: 'Faroese';
402
+ fr: 'French';
403
+ fy: 'Western Frisian';
404
+ ga: 'Irish';
405
+ gd: 'Scottish Gaelic';
406
+ gl: 'Galician';
407
+ gn: 'Guarani';
408
+ gu: 'Gujarati';
409
+ gv: 'Manx';
410
+ ha: 'Hausa';
411
+ he: 'Hebrew';
412
+ hi: 'Hindi';
413
+ ho: 'Hiri Motu';
414
+ hr: 'Croatian';
415
+ ht: 'Haitian Creole';
416
+ hu: 'Hungarian';
417
+ hy: 'Armenian';
418
+ hz: 'Herero';
419
+ ia: 'Interlingua';
420
+ id: 'Indonesian';
421
+ ie: 'Interlingue';
422
+ ig: 'Igbo';
423
+ ii: 'Sichuan Yi';
424
+ ik: 'Inupiaq';
425
+ io: 'Ido';
426
+ is: 'Icelandic';
427
+ it: 'Italian';
428
+ iu: 'Inuktitut';
429
+ ja: 'Japanese';
430
+ jv: 'Javanese';
431
+ ka: 'Georgian';
432
+ kg: 'Kongo';
433
+ ki: 'Kikuyu';
434
+ kj: 'Kuanyama';
435
+ kk: 'Kazakh';
436
+ kl: 'Kalaallisut';
437
+ km: 'Khmer';
438
+ kn: 'Kannada';
439
+ ko: 'Korean';
440
+ kr: 'Kanuri';
441
+ ks: 'Kashmiri';
442
+ ku: 'Kurdish';
443
+ kv: 'Komi';
444
+ kw: 'Cornish';
445
+ ky: 'Kyrgyz';
446
+ la: 'Latin';
447
+ lb: 'Luxembourgish';
448
+ lg: 'Ganda';
449
+ li: 'Limburgish';
450
+ ln: 'Lingala';
451
+ lo: 'Lao';
452
+ lt: 'Lithuanian';
453
+ lu: 'Luba-Katanga';
454
+ lv: 'Latvian';
455
+ mg: 'Malagasy';
456
+ mh: 'Marshallese';
457
+ mi: 'Māori';
458
+ mk: 'Macedonian';
459
+ ml: 'Malayalam';
460
+ mn: 'Mongolian';
461
+ mr: 'Marathi';
462
+ ms: 'Malay';
463
+ mt: 'Maltese';
464
+ my: 'Burmese';
465
+ na: 'Nauru';
466
+ nb: 'Norwegian Bokmål';
467
+ nd: 'North Ndebele';
468
+ ne: 'Nepali';
469
+ ng: 'Ndonga';
470
+ nl: 'Dutch';
471
+ nn: 'Norwegian Nynorsk';
472
+ no: 'Norwegian';
473
+ nr: 'South Ndebele';
474
+ nv: 'Navajo';
475
+ ny: 'Nyanja';
476
+ oc: 'Occitan';
477
+ oj: 'Ojibwa';
478
+ om: 'Oromo';
479
+ or: 'Odia';
480
+ os: 'Ossetic';
481
+ pa: 'Punjabi';
482
+ pi: 'Pali';
483
+ pl: 'Polish';
484
+ ps: 'Pashto';
485
+ pt: 'Portuguese';
486
+ qu: 'Quechua';
487
+ rm: 'Romansh';
488
+ rn: 'Rundi';
489
+ ro: 'Romanian';
490
+ ru: 'Russian';
491
+ rw: 'Kinyarwanda';
492
+ sa: 'Sanskrit';
493
+ sc: 'Sardinian';
494
+ sd: 'Sindhi';
495
+ se: 'Northern Sami';
496
+ sg: 'Sango';
497
+ si: 'Sinhala';
498
+ sk: 'Slovak';
499
+ sl: 'Slovenian';
500
+ sm: 'Samoan';
501
+ sn: 'Shona';
502
+ so: 'Somali';
503
+ sq: 'Albanian';
504
+ sr: 'Serbian';
505
+ ss: 'Swati';
506
+ st: 'Southern Sotho';
507
+ su: 'Sundanese';
508
+ sv: 'Swedish';
509
+ sw: 'Swahili';
510
+ ta: 'Tamil';
511
+ te: 'Telugu';
512
+ tg: 'Tajik';
513
+ th: 'Thai';
514
+ ti: 'Tigrinya';
515
+ tk: 'Turkmen';
516
+ tl: 'Filipino';
517
+ tn: 'Tswana';
518
+ to: 'Tongan';
519
+ tr: 'Turkish';
520
+ ts: 'Tsonga';
521
+ tt: 'Tatar';
522
+ tw: 'Akan';
523
+ ty: 'Tahitian';
524
+ ug: 'Uyghur';
525
+ uk: 'Ukrainian';
526
+ ur: 'Urdu';
527
+ uz: 'Uzbek';
528
+ ve: 'Venda';
529
+ vi: 'Vietnamese';
530
+ vo: 'Volapük';
531
+ wa: 'Walloon';
532
+ wo: 'Wolof';
533
+ xh: 'Xhosa';
534
+ yi: 'Yiddish';
535
+ yo: 'Yoruba';
536
+ za: 'Zhuang';
537
+ zh: 'Chinese';
538
+ zu: 'Zulu';
539
+ };
540
+
541
+ /** The languages configured in `I18nConfiguration` or all ISO languages */
542
+ export declare type Language = ExtractConfig<I18nConfiguration, ISOLanguage, 'languages'>;
543
+
544
+ /** Create a _reactive_ translator object from the given options */
545
+ export declare function makeTranslator(options: I18nOptions): Translator;
546
+
547
+ /** Prettify our `Translations` exported type */
548
+ declare type PrettifyTranslation<T> = {
549
+ [l in keyof T]: T[l];
550
+ };
551
+
552
+ /**
553
+ * A type describing the translations for a given translation key.
554
+ *
555
+ * When the `I18nConfig` interface is properly merged with and its contains
556
+ * the `languages` property, this type will represent the list of required
557
+ * translation keys (languages) required for each translation.
558
+ *
559
+ * When left unconfigured, all ISO languages will be considered as optional.
560
+ */
561
+ export declare type Translation = PrettifyTranslation<BaseTranslation & ExtendedTranslation>;
562
+
563
+ /**
564
+ * All known translation keys.
565
+ *
566
+ * When the `I18nConfig` interface is properly merged with and its contains
567
+ * the `translationKeys` property, this type will represent the list of
568
+ * translations keys available to the `t(...)` and `tc(...)` methods.
569
+ *
570
+ * When left unconfigured, this type will be `string`.
571
+ */
572
+ export declare type TranslationKey = ExtractConfig<I18nConfiguration, string, 'translationKeys'>;
573
+
574
+ /**
575
+ * Parameters for the formatting of a translation.
576
+ *
577
+ * This type is used to pass parameters to the `t` and `tc` methods of the
578
+ * translator, allowing for the interpolation of values into the translated
579
+ * message.
580
+ *
581
+ * When the parameter value is a number, it will be formatted using the `n`
582
+ * formatter before being interpolated into the message.
583
+ */
584
+ export declare interface TranslationParams {
585
+ [key: string]: string | number;
586
+ }
587
+
588
+ /**
589
+ * Options to initialize the translations handled by the translation system.
590
+ *
591
+ * Shared translations are defined as a key-value pair, where the key is the
592
+ * identifier of the translation, and the value is an object containing the
593
+ * translations for each language.
594
+ */
595
+ export declare interface Translations {
596
+ readonly [key: string]: Translation;
597
+ }
598
+
599
+ /**
600
+ * The translator interface for the application.
601
+ *
602
+ * This interface provides methods to translate messages, format numbers, and
603
+ * format dates and times.
604
+ *
605
+ * Configured instances can be accessed using the `useI18n()` composition
606
+ * function, which will provide an instance of the translator.
607
+ */
608
+ export declare interface Translator {
609
+ /** The current ISO-639-1 language code used by this translator. */
610
+ language: ISOLanguage;
611
+ /** The region (if any) used by thus translator to localize translations. */
612
+ region: ISOCountry | undefined;
613
+ /** The `Locale` used by this translator (merges `language` and `region`) */
614
+ locale: Intl.Locale;
615
+ /**
616
+ * Return the (possibly parameterized) translation for the specified message
617
+ * in the current language.
618
+ *
619
+ * Internally, this method uses the `tc(...)` function with `n=1`, in order to
620
+ * avoid duplication of message keys
621
+ */
622
+ t(key: TranslationKey | Translation, params?: TranslationParams): string;
623
+ /**
624
+ * Return the (possibly parameterized) translation for the specified message
625
+ * in the current language, with pluralization.
626
+ *
627
+ * For pluralization, translation messages should be separated by the pipe
628
+ * character, like in Vue I18N. Example:
629
+ *
630
+ * * `" one apple | {n} apples "` when _two_ translations are separated by a
631
+ * pipe, the first will be used for singular, the second for zero or plural
632
+ * * `" no apples | one apple | {n} apples "` when _three_ translations are
633
+ * separated by a pipe, the first will be used for zero, the second for
634
+ * singular, the second for zero or plural
635
+ *
636
+ * For convenience, the `{n}` message parameter will always be contextualized
637
+ * with the number, unless overridden in the `params` themselves.
638
+ */
639
+ tc(key: TranslationKey | Translation, n: number, params?: TranslationParams): string;
640
+ /**
641
+ * Format a number into a string according to the current language.
642
+ *
643
+ * If the `currency` parameter is set, the number will be formatted as a
644
+ * currency value, using the specified currency symbol.
645
+ */
646
+ n(value?: number | bigint | null | undefined, currency?: string): string;
647
+ /**
648
+ * Format a number into a string according to the current language.
649
+ *
650
+ * When `format` is provided, it will be used to configure the number format,
651
+ * otherwise the default `format.numberFormat` plugin option will be used.
652
+ */
653
+ n(value?: number | bigint | null | undefined, format?: Intl.NumberFormatOptions): string;
654
+ d: {
655
+ /**
656
+ * Format date and time according to the current language.
657
+ *
658
+ * When `style` is provided, it will be used to configure the date and time
659
+ * format, otherwise the default `format.dateTimeFormat` plugin option will
660
+ * be used.
661
+ */
662
+ (date?: DateInput, style?: DateTimeFormats['dateTimeFormat']): string;
663
+ /**
664
+ * Format the date part (without time) according to the current language.
665
+ *
666
+ * When `style` is provided, it will be used to configure the date and time
667
+ * format, otherwise the default `format.dateOnlyFormat` plugin option will
668
+ * be used.
669
+ */
670
+ date(date?: DateInput, style?: DateTimeFormats['dateOnlyFormat']): string;
671
+ /**
672
+ * Format the time part (without date) according to the current language.
673
+ *
674
+ * When `style` is provided, it will be used to configure the date and time
675
+ * format, otherwise the default `format.timeOnlyFormat` plugin option will
676
+ * be used.
677
+ */
678
+ time(date?: DateInput, style?: DateTimeFormats['timeOnlyFormat']): string;
679
+ };
680
+ }
681
+
682
+ /** Retrieve the translator instance from the Vue app */
683
+ export declare function useTranslator(): Translator;
684
+
685
+ export { }
686
+
687
+
688
+ declare module 'vue' {
689
+ interface ComponentCustomProperties {
690
+ /** Translate a message according to the current language */
691
+ $t: Translator['t'];
692
+ /**
693
+ * Return the (possibly parameterized) translation for the specified message
694
+ * in the current language, with pluralization.
695
+ */
696
+ $tc: Translator['tc'];
697
+ /** Format a number into a string according to the current language */
698
+ $n: Translator['n'];
699
+ /**
700
+ * Format date and time using the specified style (defaults to `medium`)
701
+ * according to the current language
702
+ */
703
+ $d: Translator['d'];
704
+ }
705
+ }