@i18n-micro/vue 1.3.2 → 1.3.4

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,565 @@
1
+ import { BaseI18n } from '@i18n-micro/core';
2
+ import { CleanTranslation } from '@i18n-micro/types';
3
+ import { Component } from 'vue';
4
+ import { ComponentOptionsMixin } from 'vue';
5
+ import { ComponentProvideOptions } from 'vue';
6
+ import { CSSProperties } from 'vue';
7
+ import { defaultPlural } from '@i18n-micro/core';
8
+ import { DefineComponent } from 'vue';
9
+ import { ExtractPropTypes } from 'vue';
10
+ import { FormatService } from '@i18n-micro/core';
11
+ import { Getter } from '@i18n-micro/types';
12
+ import { InjectionKey } from 'vue';
13
+ import { interpolate } from '@i18n-micro/core';
14
+ import { Locale } from '@i18n-micro/types';
15
+ import { LocaleCode } from '@i18n-micro/types';
16
+ import { Params } from '@i18n-micro/types';
17
+ import { Plugin as Plugin_2 } from 'vue';
18
+ import { PluralFunc } from '@i18n-micro/types';
19
+ import { PropType } from 'vue';
20
+ import { PublicProps } from 'vue';
21
+ import { Ref } from 'vue';
22
+ import { RendererElement } from 'vue';
23
+ import { RendererNode } from 'vue';
24
+ import { Router } from 'vue-router';
25
+ import { TranslationKey } from '@i18n-micro/types';
26
+ import { Translations } from '@i18n-micro/types';
27
+ import { TranslationStorage } from '@i18n-micro/core';
28
+ import { VNode } from 'vue';
29
+ import { WritableComputedRef } from 'vue';
30
+
31
+ export { CleanTranslation }
32
+
33
+ export declare function createI18n(options: CreateI18nOptions): I18nPlugin;
34
+
35
+ declare interface CreateI18nOptions extends VueI18nOptions {
36
+ routingStrategy?: I18nRoutingStrategy;
37
+ /**
38
+ * Array of locale configurations
39
+ * If provided, will be automatically provided to the app via I18nLocalesKey
40
+ */
41
+ locales?: Locale[];
42
+ /**
43
+ * Default locale code
44
+ * If provided, will be automatically provided to the app via I18nDefaultLocaleKey
45
+ */
46
+ defaultLocale?: string;
47
+ }
48
+
49
+ /**
50
+ * Factory for Vue Router adapter
51
+ * Implements routing utilities for Vue Router
52
+ * Uses vue-router APIs for navigation and path resolution
53
+ */
54
+ export declare function createVueRouterAdapter(router: Router, locales: Locale[], defaultLocale: string): I18nRoutingStrategy;
55
+
56
+ export { defaultPlural }
57
+
58
+ export { FormatService }
59
+
60
+ export { Getter }
61
+
62
+ export declare const I18nDefaultLocaleKey: InjectionKey<string>;
63
+
64
+ export declare const I18nGroup: DefineComponent<I18nGroupProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<I18nGroupProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
65
+
66
+ declare interface I18nGroupProps {
67
+ prefix: string;
68
+ groupClass?: string;
69
+ }
70
+
71
+ export declare const I18nInjectionKey: InjectionKey<VueI18n>;
72
+
73
+ export declare const I18nLink: DefineComponent<ExtractPropTypes< {
74
+ to: {
75
+ type: PropType<string | {
76
+ path?: string;
77
+ }>;
78
+ required: true;
79
+ };
80
+ activeStyle: {
81
+ type: PropType<CSSProperties>;
82
+ default: () => {};
83
+ };
84
+ localeRoute: {
85
+ type: PropType<(to: string | {
86
+ path?: string;
87
+ }, locale?: string) => string | {
88
+ path?: string;
89
+ }>;
90
+ default: undefined;
91
+ };
92
+ }>, () => VNode<RendererNode, RendererElement, {
93
+ [key: string]: any;
94
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
95
+ to: {
96
+ type: PropType<string | {
97
+ path?: string;
98
+ }>;
99
+ required: true;
100
+ };
101
+ activeStyle: {
102
+ type: PropType<CSSProperties>;
103
+ default: () => {};
104
+ };
105
+ localeRoute: {
106
+ type: PropType<(to: string | {
107
+ path?: string;
108
+ }, locale?: string) => string | {
109
+ path?: string;
110
+ }>;
111
+ default: undefined;
112
+ };
113
+ }>> & Readonly<{}>, {
114
+ activeStyle: CSSProperties;
115
+ localeRoute: (to: string | {
116
+ path?: string;
117
+ }, locale?: string) => string | {
118
+ path?: string;
119
+ };
120
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
121
+
122
+ export declare const I18nLocalesKey: InjectionKey<Locale[]>;
123
+
124
+ export declare type I18nPlugin = Plugin_2 & {
125
+ global: VueI18n;
126
+ setRoutingStrategy: (strategy: I18nRoutingStrategy) => void;
127
+ };
128
+
129
+ /**
130
+ * Routing strategy interface for i18n
131
+ * Implement this interface to integrate with any router library
132
+ */
133
+ export declare interface I18nRoutingStrategy {
134
+ /**
135
+ * Returns current path (without locale prefix if needed, or full path)
136
+ * Used for determining active classes in links
137
+ */
138
+ getCurrentPath: () => string;
139
+ /**
140
+ * Component to use for rendering links (e.g., RouterLink)
141
+ */
142
+ linkComponent?: string | Component;
143
+ /**
144
+ * Function to navigate to another route/locale
145
+ */
146
+ push: (target: {
147
+ path: string;
148
+ }) => void;
149
+ /**
150
+ * Function to replace current route
151
+ */
152
+ replace: (target: {
153
+ path: string;
154
+ }) => void;
155
+ /**
156
+ * Generate path for specific locale
157
+ */
158
+ resolvePath?: (to: string | {
159
+ path?: string;
160
+ }, locale: string) => string | {
161
+ path?: string;
162
+ };
163
+ /**
164
+ * (Optional) Get current route object for SEO/Meta tags
165
+ */
166
+ getRoute?: () => {
167
+ fullPath: string;
168
+ query: Record<string, unknown>;
169
+ };
170
+ }
171
+
172
+ export declare const I18nSwitcher: DefineComponent<ExtractPropTypes< {
173
+ customLabels: {
174
+ type: PropType<Record<string, string>>;
175
+ default: () => {};
176
+ };
177
+ customWrapperStyle: {
178
+ type: PropType<CSSProperties>;
179
+ default: () => {};
180
+ };
181
+ customButtonStyle: {
182
+ type: PropType<CSSProperties>;
183
+ default: () => {};
184
+ };
185
+ customDropdownStyle: {
186
+ type: PropType<CSSProperties>;
187
+ default: () => {};
188
+ };
189
+ customItemStyle: {
190
+ type: PropType<CSSProperties>;
191
+ default: () => {};
192
+ };
193
+ customLinkStyle: {
194
+ type: PropType<CSSProperties>;
195
+ default: () => {};
196
+ };
197
+ customActiveLinkStyle: {
198
+ type: PropType<CSSProperties>;
199
+ default: () => {};
200
+ };
201
+ customDisabledLinkStyle: {
202
+ type: PropType<CSSProperties>;
203
+ default: () => {};
204
+ };
205
+ customIconStyle: {
206
+ type: PropType<CSSProperties>;
207
+ default: () => {};
208
+ };
209
+ locales: {
210
+ type: PropType<Locale[]>;
211
+ default: undefined;
212
+ };
213
+ currentLocale: {
214
+ type: PropType<string | (() => string)>;
215
+ default: undefined;
216
+ };
217
+ getLocaleName: {
218
+ type: PropType<() => string | null>;
219
+ default: undefined;
220
+ };
221
+ switchLocale: {
222
+ type: PropType<(locale: string) => void>;
223
+ default: undefined;
224
+ };
225
+ localeRoute: {
226
+ type: PropType<(to: string | {
227
+ path?: string;
228
+ }, locale?: string) => string | {
229
+ path?: string;
230
+ }>;
231
+ default: undefined;
232
+ };
233
+ }>, () => VNode<RendererNode, RendererElement, {
234
+ [key: string]: any;
235
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
236
+ customLabels: {
237
+ type: PropType<Record<string, string>>;
238
+ default: () => {};
239
+ };
240
+ customWrapperStyle: {
241
+ type: PropType<CSSProperties>;
242
+ default: () => {};
243
+ };
244
+ customButtonStyle: {
245
+ type: PropType<CSSProperties>;
246
+ default: () => {};
247
+ };
248
+ customDropdownStyle: {
249
+ type: PropType<CSSProperties>;
250
+ default: () => {};
251
+ };
252
+ customItemStyle: {
253
+ type: PropType<CSSProperties>;
254
+ default: () => {};
255
+ };
256
+ customLinkStyle: {
257
+ type: PropType<CSSProperties>;
258
+ default: () => {};
259
+ };
260
+ customActiveLinkStyle: {
261
+ type: PropType<CSSProperties>;
262
+ default: () => {};
263
+ };
264
+ customDisabledLinkStyle: {
265
+ type: PropType<CSSProperties>;
266
+ default: () => {};
267
+ };
268
+ customIconStyle: {
269
+ type: PropType<CSSProperties>;
270
+ default: () => {};
271
+ };
272
+ locales: {
273
+ type: PropType<Locale[]>;
274
+ default: undefined;
275
+ };
276
+ currentLocale: {
277
+ type: PropType<string | (() => string)>;
278
+ default: undefined;
279
+ };
280
+ getLocaleName: {
281
+ type: PropType<() => string | null>;
282
+ default: undefined;
283
+ };
284
+ switchLocale: {
285
+ type: PropType<(locale: string) => void>;
286
+ default: undefined;
287
+ };
288
+ localeRoute: {
289
+ type: PropType<(to: string | {
290
+ path?: string;
291
+ }, locale?: string) => string | {
292
+ path?: string;
293
+ }>;
294
+ default: undefined;
295
+ };
296
+ }>> & Readonly<{}>, {
297
+ localeRoute: (to: string | {
298
+ path?: string;
299
+ }, locale?: string) => string | {
300
+ path?: string;
301
+ };
302
+ customLabels: Record<string, string>;
303
+ customWrapperStyle: CSSProperties;
304
+ customButtonStyle: CSSProperties;
305
+ customDropdownStyle: CSSProperties;
306
+ customItemStyle: CSSProperties;
307
+ customLinkStyle: CSSProperties;
308
+ customActiveLinkStyle: CSSProperties;
309
+ customDisabledLinkStyle: CSSProperties;
310
+ customIconStyle: CSSProperties;
311
+ locales: Locale[];
312
+ currentLocale: string | (() => string);
313
+ getLocaleName: () => string | null;
314
+ switchLocale: (locale: string) => void;
315
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
316
+
317
+ export declare const I18nT: DefineComponent<ExtractPropTypes< {
318
+ keypath: {
319
+ type: PropType<TranslationKey>;
320
+ required: true;
321
+ };
322
+ plural: {
323
+ type: PropType<number | string>;
324
+ };
325
+ tag: {
326
+ type: PropType<string>;
327
+ default: string;
328
+ };
329
+ params: {
330
+ type: PropType<Record<string, string | number | boolean>>;
331
+ default: () => {};
332
+ };
333
+ defaultValue: {
334
+ type: PropType<string>;
335
+ default: string;
336
+ };
337
+ html: {
338
+ type: PropType<boolean>;
339
+ default: boolean;
340
+ };
341
+ hideIfEmpty: {
342
+ type: PropType<boolean>;
343
+ default: boolean;
344
+ };
345
+ customPluralRule: {
346
+ type: PropType<PluralFunc>;
347
+ default: null;
348
+ };
349
+ number: {
350
+ type: PropType<number | string>;
351
+ };
352
+ date: {
353
+ type: PropType<Date | string | number>;
354
+ };
355
+ relativeDate: {
356
+ type: PropType<Date | string | number>;
357
+ };
358
+ }>, () => string | VNode<RendererNode, RendererElement, {
359
+ [key: string]: any;
360
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
361
+ keypath: {
362
+ type: PropType<TranslationKey>;
363
+ required: true;
364
+ };
365
+ plural: {
366
+ type: PropType<number | string>;
367
+ };
368
+ tag: {
369
+ type: PropType<string>;
370
+ default: string;
371
+ };
372
+ params: {
373
+ type: PropType<Record<string, string | number | boolean>>;
374
+ default: () => {};
375
+ };
376
+ defaultValue: {
377
+ type: PropType<string>;
378
+ default: string;
379
+ };
380
+ html: {
381
+ type: PropType<boolean>;
382
+ default: boolean;
383
+ };
384
+ hideIfEmpty: {
385
+ type: PropType<boolean>;
386
+ default: boolean;
387
+ };
388
+ customPluralRule: {
389
+ type: PropType<PluralFunc>;
390
+ default: null;
391
+ };
392
+ number: {
393
+ type: PropType<number | string>;
394
+ };
395
+ date: {
396
+ type: PropType<Date | string | number>;
397
+ };
398
+ relativeDate: {
399
+ type: PropType<Date | string | number>;
400
+ };
401
+ }>> & Readonly<{}>, {
402
+ html: boolean;
403
+ tag: string;
404
+ params: Record<string, string | number | boolean>;
405
+ defaultValue: string;
406
+ hideIfEmpty: boolean;
407
+ customPluralRule: PluralFunc;
408
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
409
+
410
+ export { interpolate }
411
+
412
+ export { Locale }
413
+
414
+ export { LocaleCode }
415
+
416
+ declare interface MetaLink {
417
+ [key: string]: string | undefined;
418
+ rel: string;
419
+ href: string;
420
+ hreflang?: string;
421
+ }
422
+
423
+ declare interface MetaObject {
424
+ htmlAttrs: {
425
+ lang?: string;
426
+ dir?: 'ltr' | 'rtl' | 'auto';
427
+ };
428
+ link: MetaLink[];
429
+ meta: MetaTag[];
430
+ }
431
+
432
+ declare interface MetaTag {
433
+ [key: string]: string;
434
+ property: string;
435
+ content: string;
436
+ }
437
+
438
+ export { Params }
439
+
440
+ export { PluralFunc }
441
+
442
+ export { Translations }
443
+
444
+ /**
445
+ * Get the i18n instance from the Vue app context
446
+ * Returns the same instance that was created with createI18n()
447
+ */
448
+ export declare function useI18n(options?: UseI18nOptions): {
449
+ instance: VueI18n;
450
+ locale: WritableComputedRef<string, string>;
451
+ getLocales: () => Locale[];
452
+ defaultLocale: () => string;
453
+ getLocaleName: () => string | null;
454
+ localeRoute: (to: string | {
455
+ path?: string;
456
+ }, localeCode?: string) => string | {
457
+ path?: string;
458
+ };
459
+ localePath: (to: string | {
460
+ path?: string;
461
+ }, locale?: string) => string;
462
+ switchLocale: (newLocale: string) => void;
463
+ t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeContext?: unknown) => CleanTranslation;
464
+ ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeContext?: unknown) => string;
465
+ tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string;
466
+ tn: (value: number, options?: Intl.NumberFormatOptions) => string;
467
+ td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
468
+ tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
469
+ has: (key: TranslationKey, routeContext?: unknown) => boolean;
470
+ setRoute: (routeName: string) => void;
471
+ getRoute: () => string;
472
+ getLocale: () => string;
473
+ addTranslations: (locale: string, translations: Translations, merge?: boolean) => void;
474
+ addRouteTranslations: (locale: string, routeName: string, translations: Translations, merge?: boolean) => void;
475
+ mergeTranslations: (locale: string, routeName: string, translations: Translations) => void;
476
+ clearCache: () => void;
477
+ };
478
+
479
+ export declare interface UseI18nOptions {
480
+ locales?: Locale[];
481
+ defaultLocale?: string;
482
+ }
483
+
484
+ export declare function useLocaleHead(options?: UseLocaleHeadOptions): {
485
+ metaObject: Ref< {
486
+ htmlAttrs: {
487
+ lang?: string | undefined;
488
+ dir?: "ltr" | "rtl" | "auto" | undefined;
489
+ };
490
+ link: {
491
+ [x: string]: string | undefined;
492
+ rel: string;
493
+ href: string;
494
+ hreflang?: string | undefined;
495
+ }[];
496
+ meta: {
497
+ [x: string]: string;
498
+ property: string;
499
+ content: string;
500
+ }[];
501
+ }, MetaObject | {
502
+ htmlAttrs: {
503
+ lang?: string | undefined;
504
+ dir?: "ltr" | "rtl" | "auto" | undefined;
505
+ };
506
+ link: {
507
+ [x: string]: string | undefined;
508
+ rel: string;
509
+ href: string;
510
+ hreflang?: string | undefined;
511
+ }[];
512
+ meta: {
513
+ [x: string]: string;
514
+ property: string;
515
+ content: string;
516
+ }[];
517
+ }>;
518
+ updateMeta: (canonicalQueryWhitelist?: string[]) => void;
519
+ };
520
+
521
+ export declare interface UseLocaleHeadOptions {
522
+ addDirAttribute?: boolean;
523
+ identifierAttribute?: string;
524
+ addSeoAttributes?: boolean;
525
+ baseUrl?: string | (() => string);
526
+ }
527
+
528
+ export declare class VueI18n extends BaseI18n {
529
+ private _locale;
530
+ private _fallbackLocale;
531
+ private _currentRoute;
532
+ private _revision;
533
+ readonly storage: TranslationStorage;
534
+ private listeners;
535
+ constructor(options: VueI18nOptions);
536
+ get locale(): Ref<string>;
537
+ set locale(val: Ref<string> | string);
538
+ get fallbackLocale(): Ref<string>;
539
+ set fallbackLocale(val: Ref<string> | string);
540
+ get currentRoute(): Ref<string>;
541
+ setRoute(routeName: string): void;
542
+ getLocale(): string;
543
+ getFallbackLocale(): string;
544
+ getRoute(): string;
545
+ addTranslations(locale: string, translations: Translations, merge?: boolean): void;
546
+ addRouteTranslations(locale: string, routeName: string, translations: Translations, merge?: boolean): void;
547
+ mergeTranslations(locale: string, routeName: string, translations: Translations): void;
548
+ clearCache(): void;
549
+ subscribeToChanges(cb: () => void): () => void;
550
+ private notifyListeners;
551
+ getAllTranslations(): Record<string, Translations>;
552
+ getStorage(): TranslationStorage;
553
+ getRouteCache(): Record<string, Translations>;
554
+ }
555
+
556
+ export declare interface VueI18nOptions {
557
+ locale: string;
558
+ fallbackLocale?: string;
559
+ messages?: Record<string, Translations>;
560
+ plural?: PluralFunc;
561
+ missingWarn?: boolean;
562
+ missingHandler?: (locale: string, key: string, routeName: string) => void;
563
+ }
564
+
565
+ export { }