@i18n-micro/types 1.1.6 → 1.2.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.
- package/dist/index.d.ts +41 -2
- package/package.json +1 -1
- package/src/index.ts +42 -2
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,29 @@ export type TranslationKey = keyof DefineLocaleMessage extends never ? string :
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export type ScopedKey<Scope extends string> = Extract<TranslationKey, `${Scope}.${string}`>;
|
|
31
|
+
/**
|
|
32
|
+
* Locale configuration object.
|
|
33
|
+
*
|
|
34
|
+
* Supports arbitrary custom properties via the index signature `[key: string]: unknown`.
|
|
35
|
+
* To get full TypeScript support for your custom properties, use module augmentation:
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // app/i18n.d.ts (or any .d.ts file included in your tsconfig)
|
|
39
|
+
* declare module '@i18n-micro/types' {
|
|
40
|
+
* interface Locale {
|
|
41
|
+
* flag?: string
|
|
42
|
+
* currency?: string
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Then access them with full typing:
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const locales = $getLocales()
|
|
50
|
+
* locales[0].flag // string | undefined (typed!)
|
|
51
|
+
* locales[0].currency // string | undefined (typed!)
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
31
54
|
export interface Locale {
|
|
32
55
|
/** BCP-47 locale code (e.g. `'en'`, `'de-DE'`, `'zh-Hans'`). Used in URLs and as file/key identifier. */
|
|
33
56
|
code: LocaleCode;
|
|
@@ -35,6 +58,11 @@ export interface Locale {
|
|
|
35
58
|
disabled?: boolean;
|
|
36
59
|
/** ISO 639-1 / BCP-47 tag for `<html lang>` and `hreflang` SEO attributes (e.g. `'en-US'`). */
|
|
37
60
|
iso?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Open Graph locale for `og:locale` / `og:locale:alternate` meta `content` (e.g. `ar_AE`).
|
|
63
|
+
* If omitted or empty, `iso` is used (then `code`).
|
|
64
|
+
*/
|
|
65
|
+
og?: string;
|
|
38
66
|
/** Text direction. Reflected in `<html dir>` when the locale is active. */
|
|
39
67
|
dir?: 'ltr' | 'rtl' | 'auto';
|
|
40
68
|
/** Human-readable name shown in language switchers (e.g. `'English'`, `'Deutsch'`). */
|
|
@@ -352,6 +380,17 @@ export interface ModuleOptions {
|
|
|
352
380
|
* @default 0
|
|
353
381
|
*/
|
|
354
382
|
cacheTtl?: number;
|
|
383
|
+
/**
|
|
384
|
+
* Value used for cache-busting translation requests (`?v=...`).
|
|
385
|
+
*
|
|
386
|
+
* When not provided, the module falls back to `Date.now()` (non-deterministic).
|
|
387
|
+
* For reproducible/rolling deployments, set this to a stable value
|
|
388
|
+
* (e.g. a git SHA or build number).
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* i18n: { dateBuild: 'e3b0c442' }
|
|
392
|
+
*/
|
|
393
|
+
dateBuild?: string | number;
|
|
355
394
|
/**
|
|
356
395
|
* Bucket for experimental/unstable options.
|
|
357
396
|
* Contents may change or be removed without notice between minor versions.
|
|
@@ -363,8 +402,8 @@ export interface ModuleOptions {
|
|
|
363
402
|
* Includes resolved values and build-time metadata.
|
|
364
403
|
*/
|
|
365
404
|
export interface ModuleOptionsExtend extends ModuleOptions {
|
|
366
|
-
/**
|
|
367
|
-
dateBuild: number;
|
|
405
|
+
/** Value used for cache-busting translation requests (`?v=...`). */
|
|
406
|
+
dateBuild: string | number;
|
|
368
407
|
/** Whether the Nuxt app uses hash-based routing (`router.options.hashMode`). */
|
|
369
408
|
hashMode: boolean;
|
|
370
409
|
/** Whether the current build is a static site generation (SSG / `nuxi generate`). */
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -33,6 +33,29 @@ export type TranslationKey = keyof DefineLocaleMessage extends never ? string :
|
|
|
33
33
|
*/
|
|
34
34
|
export type ScopedKey<Scope extends string> = Extract<TranslationKey, `${Scope}.${string}`>
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Locale configuration object.
|
|
38
|
+
*
|
|
39
|
+
* Supports arbitrary custom properties via the index signature `[key: string]: unknown`.
|
|
40
|
+
* To get full TypeScript support for your custom properties, use module augmentation:
|
|
41
|
+
*
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // app/i18n.d.ts (or any .d.ts file included in your tsconfig)
|
|
44
|
+
* declare module '@i18n-micro/types' {
|
|
45
|
+
* interface Locale {
|
|
46
|
+
* flag?: string
|
|
47
|
+
* currency?: string
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Then access them with full typing:
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const locales = $getLocales()
|
|
55
|
+
* locales[0].flag // string | undefined (typed!)
|
|
56
|
+
* locales[0].currency // string | undefined (typed!)
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
36
59
|
export interface Locale {
|
|
37
60
|
/** BCP-47 locale code (e.g. `'en'`, `'de-DE'`, `'zh-Hans'`). Used in URLs and as file/key identifier. */
|
|
38
61
|
code: LocaleCode
|
|
@@ -40,6 +63,11 @@ export interface Locale {
|
|
|
40
63
|
disabled?: boolean
|
|
41
64
|
/** ISO 639-1 / BCP-47 tag for `<html lang>` and `hreflang` SEO attributes (e.g. `'en-US'`). */
|
|
42
65
|
iso?: string
|
|
66
|
+
/**
|
|
67
|
+
* Open Graph locale for `og:locale` / `og:locale:alternate` meta `content` (e.g. `ar_AE`).
|
|
68
|
+
* If omitted or empty, `iso` is used (then `code`).
|
|
69
|
+
*/
|
|
70
|
+
og?: string
|
|
43
71
|
/** Text direction. Reflected in `<html dir>` when the locale is active. */
|
|
44
72
|
dir?: 'ltr' | 'rtl' | 'auto'
|
|
45
73
|
/** Human-readable name shown in language switchers (e.g. `'English'`, `'Deutsch'`). */
|
|
@@ -402,6 +430,18 @@ export interface ModuleOptions {
|
|
|
402
430
|
*/
|
|
403
431
|
cacheTtl?: number
|
|
404
432
|
|
|
433
|
+
/**
|
|
434
|
+
* Value used for cache-busting translation requests (`?v=...`).
|
|
435
|
+
*
|
|
436
|
+
* When not provided, the module falls back to `Date.now()` (non-deterministic).
|
|
437
|
+
* For reproducible/rolling deployments, set this to a stable value
|
|
438
|
+
* (e.g. a git SHA or build number).
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* i18n: { dateBuild: 'e3b0c442' }
|
|
442
|
+
*/
|
|
443
|
+
dateBuild?: string | number
|
|
444
|
+
|
|
405
445
|
/**
|
|
406
446
|
* Bucket for experimental/unstable options.
|
|
407
447
|
* Contents may change or be removed without notice between minor versions.
|
|
@@ -414,8 +454,8 @@ export interface ModuleOptions {
|
|
|
414
454
|
* Includes resolved values and build-time metadata.
|
|
415
455
|
*/
|
|
416
456
|
export interface ModuleOptionsExtend extends ModuleOptions {
|
|
417
|
-
/**
|
|
418
|
-
dateBuild: number
|
|
457
|
+
/** Value used for cache-busting translation requests (`?v=...`). */
|
|
458
|
+
dateBuild: string | number
|
|
419
459
|
/** Whether the Nuxt app uses hash-based routing (`router.options.hashMode`). */
|
|
420
460
|
hashMode: boolean
|
|
421
461
|
/** Whether the current build is a static site generation (SSG / `nuxi generate`). */
|