@i18n-micro/types 1.1.5 → 1.1.7

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 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;
@@ -171,6 +194,13 @@ export interface ModuleOptions {
171
194
  * @default true
172
195
  */
173
196
  hooks?: boolean;
197
+ /**
198
+ * Register built-in i18n components (`<i18n-link>`, `<i18n-switcher>`, `<i18n-t>`, `<i18n-group>`).
199
+ * Set to `false` to disable automatic component registration (e.g. if you don't use them
200
+ * and want to reduce the module footprint).
201
+ * @default true
202
+ */
203
+ components?: boolean;
174
204
  /**
175
205
  * The locale to use when no locale can be determined from URL or user preferences.
176
206
  * Also used as the fallback locale for missing translations when `fallbackLocale` is not set.
@@ -340,11 +370,22 @@ export interface ModuleOptions {
340
370
  */
341
371
  cacheMaxSize?: number;
342
372
  /**
343
- * Time-to-live (in milliseconds) for cached translation entries.
373
+ * Time-to-live (in seconds) for cached translation entries.
344
374
  * `0` means entries never expire.
345
375
  * @default 0
346
376
  */
347
377
  cacheTtl?: number;
378
+ /**
379
+ * Value used for cache-busting translation requests (`?v=...`).
380
+ *
381
+ * When not provided, the module falls back to `Date.now()` (non-deterministic).
382
+ * For reproducible/rolling deployments, set this to a stable value
383
+ * (e.g. a git SHA or build number).
384
+ *
385
+ * @example
386
+ * i18n: { dateBuild: 'e3b0c442' }
387
+ */
388
+ dateBuild?: string | number;
348
389
  /**
349
390
  * Bucket for experimental/unstable options.
350
391
  * Contents may change or be removed without notice between minor versions.
@@ -356,8 +397,8 @@ export interface ModuleOptions {
356
397
  * Includes resolved values and build-time metadata.
357
398
  */
358
399
  export interface ModuleOptionsExtend extends ModuleOptions {
359
- /** Unix timestamp (ms) of the last build. Used for cache-busting translation requests. */
360
- dateBuild: number;
400
+ /** Value used for cache-busting translation requests (`?v=...`). */
401
+ dateBuild: string | number;
361
402
  /** Whether the Nuxt app uses hash-based routing (`router.options.hashMode`). */
362
403
  hashMode: boolean;
363
404
  /** Whether the current build is a static site generation (SSG / `nuxi generate`). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-micro/types",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "repository": "s00d/nuxt-i18n-micro",
6
6
  "license": "MIT",
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
@@ -195,6 +218,14 @@ export interface ModuleOptions {
195
218
  */
196
219
  hooks?: boolean
197
220
 
221
+ /**
222
+ * Register built-in i18n components (`<i18n-link>`, `<i18n-switcher>`, `<i18n-t>`, `<i18n-group>`).
223
+ * Set to `false` to disable automatic component registration (e.g. if you don't use them
224
+ * and want to reduce the module footprint).
225
+ * @default true
226
+ */
227
+ components?: boolean
228
+
198
229
  /**
199
230
  * The locale to use when no locale can be determined from URL or user preferences.
200
231
  * Also used as the fallback locale for missing translations when `fallbackLocale` is not set.
@@ -388,12 +419,24 @@ export interface ModuleOptions {
388
419
  cacheMaxSize?: number
389
420
 
390
421
  /**
391
- * Time-to-live (in milliseconds) for cached translation entries.
422
+ * Time-to-live (in seconds) for cached translation entries.
392
423
  * `0` means entries never expire.
393
424
  * @default 0
394
425
  */
395
426
  cacheTtl?: number
396
427
 
428
+ /**
429
+ * Value used for cache-busting translation requests (`?v=...`).
430
+ *
431
+ * When not provided, the module falls back to `Date.now()` (non-deterministic).
432
+ * For reproducible/rolling deployments, set this to a stable value
433
+ * (e.g. a git SHA or build number).
434
+ *
435
+ * @example
436
+ * i18n: { dateBuild: 'e3b0c442' }
437
+ */
438
+ dateBuild?: string | number
439
+
397
440
  /**
398
441
  * Bucket for experimental/unstable options.
399
442
  * Contents may change or be removed without notice between minor versions.
@@ -406,8 +449,8 @@ export interface ModuleOptions {
406
449
  * Includes resolved values and build-time metadata.
407
450
  */
408
451
  export interface ModuleOptionsExtend extends ModuleOptions {
409
- /** Unix timestamp (ms) of the last build. Used for cache-busting translation requests. */
410
- dateBuild: number
452
+ /** Value used for cache-busting translation requests (`?v=...`). */
453
+ dateBuild: string | number
411
454
  /** Whether the Nuxt app uses hash-based routing (`router.options.hashMode`). */
412
455
  hashMode: boolean
413
456
  /** Whether the current build is a static site generation (SSG / `nuxi generate`). */