@gunshi/plugin-i18n 0.27.4 → 0.27.6

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.
Files changed (3) hide show
  1. package/lib/index.d.ts +10 -10
  2. package/lib/index.js +14 -14
  3. package/package.json +10 -10
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Args, Awaitable, Command, CommandContext, DefaultGunshiParams, ExtendContext, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, PluginWithExtension, Prettify } from "@gunshi/plugin";
2
2
 
3
- //#region ../../node_modules/.pnpm/args-tokens@0.23.0/node_modules/args-tokens/lib/resolver-D64nGlCD.d.ts
3
+ //#region ../../node_modules/.pnpm/args-tokens@0.23.1/node_modules/args-tokens/lib/resolver.d.ts
4
4
 
5
5
  //#region src/resolver.d.ts
6
6
  /**
@@ -436,7 +436,7 @@ type ExtendContext$1 = Record<string, unknown>;
436
436
  *
437
437
  * @since v0.27.0
438
438
  */
439
- interface GunshiParams$1<P$1 extends {
439
+ interface GunshiParams$1<P extends {
440
440
  args?: Args$1;
441
441
  extensions?: ExtendContext$1;
442
442
  } = {
@@ -446,13 +446,13 @@ interface GunshiParams$1<P$1 extends {
446
446
  /**
447
447
  * Command argument definitions.
448
448
  */
449
- args: P$1 extends {
449
+ args: P extends {
450
450
  args: infer A extends Args$1;
451
451
  } ? A : Args$1;
452
452
  /**
453
453
  * Command context extensions.
454
454
  */
455
- extensions: P$1 extends {
455
+ extensions: P extends {
456
456
  extensions: infer E extends ExtendContext$1;
457
457
  } ? E : {};
458
458
  }
@@ -525,9 +525,9 @@ type CommandBuiltinKeys = GenerateNamespacedKey<BuiltinResourceKeys>;
525
525
  * Command i18n option keys.
526
526
  * The command i18n option keys are used by the i18n plugin for translation.
527
527
  */
528
- type CommandArgKeys<A extends Args$1, C = {}, K$1 extends string = GenerateNamespacedKey<Extract<KeyOfArgs<RemovedIndex<A>>, string>, typeof ARG_PREFIX>> = C extends {
528
+ type CommandArgKeys<A extends Args$1, C = {}, K extends string = GenerateNamespacedKey<Extract<KeyOfArgs<RemovedIndex<A>>, string>, typeof ARG_PREFIX>> = C extends {
529
529
  name: infer N;
530
- } ? (N extends string ? GenerateNamespacedKey<K$1, N> : K$1) : K$1;
530
+ } ? (N extends string ? GenerateNamespacedKey<K, N> : K) : K;
531
531
  /**
532
532
  * Resolve translation keys for command context.
533
533
  */
@@ -550,7 +550,7 @@ R extends string = keyof RemovedIndex<E>, T extends string = (C extends {
550
550
  * @param key - The built-in key to resolve.
551
551
  * @returns Prefixed built-in key.
552
552
  */
553
- declare function resolveBuiltInKey<K$1 extends string = CommandBuiltinResourceKeys>(key: K$1): GenerateNamespacedKey<K$1>;
553
+ declare function resolveBuiltInKey<K extends string = CommandBuiltinResourceKeys>(key: K): GenerateNamespacedKey<K>;
554
554
  /**
555
555
  * Resolve a namespaced key for argument resources.
556
556
  *
@@ -563,7 +563,7 @@ declare function resolveBuiltInKey<K$1 extends string = CommandBuiltinResourceKe
563
563
  * @param name - The command name.
564
564
  * @returns Prefixed argument key.
565
565
  */
566
- declare function resolveArgKey<A extends Args$1 = DefaultGunshiParams$1['args'], K$1 extends string = KeyOfArgs<RemovedIndex<A>>>(key: K$1, name?: string): string;
566
+ declare function resolveArgKey<A extends Args$1 = DefaultGunshiParams$1['args'], K extends string = KeyOfArgs<RemovedIndex<A>>>(key: K, name?: string): string;
567
567
  /**
568
568
  * Resolve a namespaced key for non-built-in resources.
569
569
  *
@@ -575,7 +575,7 @@ declare function resolveArgKey<A extends Args$1 = DefaultGunshiParams$1['args'],
575
575
  * @param name - The command name.
576
576
  * @returns Prefixed non-built-in key.
577
577
  */
578
- declare function resolveKey<T extends Record<string, string> = {}, K$1 extends string = (keyof T extends string ? keyof T : string)>(key: K$1, name?: string): string;
578
+ declare function resolveKey<T extends Record<string, string> = {}, K extends string = (keyof T extends string ? keyof T : string)>(key: K, name?: string): string;
579
579
  //#endregion
580
580
  //#region src/types.d.ts
581
581
  /**
@@ -614,7 +614,7 @@ interface I18nExtension<G extends GunshiParams<any> = DefaultGunshiParams> {
614
614
  // for CommandContext
615
615
  E extends Record<string, string> = {},
616
616
  // for extended resources
617
- K$1 = ResolveTranslationKeys<A, C, E>>(key: K$1, values?: Record<string, unknown>) => string;
617
+ K = ResolveTranslationKeys<A, C, E>>(key: K, values?: Record<string, unknown>) => string;
618
618
  /**
619
619
  * Load command resources.
620
620
  *
package/lib/index.js CHANGED
@@ -376,8 +376,8 @@ function i18n(options = {}) {
376
376
  if (strKey.codePointAt(0) === BUILT_IN_PREFIX_CODE) return (localeBuiltinResources.get(localeStr) || localeBuiltinResources.get(DEFAULT_LOCALE))[strKey] || strKey;
377
377
  else return adapter.translate(localeStr, strKey, values) || "";
378
378
  }
379
- function setResource(locale$1, resource) {
380
- const targetLocaleStr = toLocaleString(toLocale(locale$1));
379
+ function setResource(locale, resource) {
380
+ const targetLocaleStr = toLocaleString(toLocale(locale));
381
381
  if (localeBuiltinResources.has(targetLocaleStr)) return;
382
382
  localeBuiltinResources.set(targetLocaleStr, mapResourceWithBuiltinKey(resource, ctx, getGlobalOptions()));
383
383
  }
@@ -387,25 +387,25 @@ function i18n(options = {}) {
387
387
  resource[DEFAULT_LOCALE] = en_US_default[globalOption];
388
388
  builtinGlobalOptionResources[globalOption] = resource;
389
389
  }
390
- for (const [locale$1, resource] of Object.entries(builtinResources)) for (const globalOption of builtinGlobalOptions) {
390
+ for (const [locale, resource] of Object.entries(builtinResources)) for (const globalOption of builtinGlobalOptions) {
391
391
  const globalOptionResource = builtinGlobalOptionResources[globalOption];
392
- globalOptionResource[locale$1] = resource[globalOption];
392
+ globalOptionResource[locale] = resource[globalOption];
393
393
  }
394
394
  for (const globalOption of builtinGlobalOptions) registerGlobalOptionResources(globalOption, builtinGlobalOptionResources[globalOption]);
395
395
  setResource(DEFAULT_LOCALE, en_US_default);
396
- for (const [locale$1, resource] of Object.entries(builtinResources)) setResource(locale$1, resource);
397
- async function loadResource(locale$1, ctx$1, cmd) {
396
+ for (const [locale, resource] of Object.entries(builtinResources)) setResource(locale, resource);
397
+ async function loadResource(locale, ctx, cmd) {
398
398
  let loaded = false;
399
- const originalResource = await loadCommandResource(toLocale(locale$1), cmd);
399
+ const originalResource = await loadCommandResource(toLocale(locale), cmd);
400
400
  if (originalResource) loaded = true;
401
- const localeStr$1 = toLocaleString(locale$1);
402
- const resource = originalResource ? await normalizeResource(originalResource, ctx$1) : Object.create(null);
401
+ const localeStr = toLocaleString(locale);
402
+ const resource = originalResource ? await normalizeResource(originalResource, ctx) : Object.create(null);
403
403
  for (const globalOption of getGlobalOptions()) if (globalOptionResources.has(globalOption)) {
404
404
  const optionResource = globalOptionResources.get(globalOption);
405
- const globalOptionKey = resolveArgKey(globalOption, ctx$1.name);
406
- resource[globalOptionKey] = optionResource[localeStr$1] || optionResource[DEFAULT_LOCALE] || Object.values(optionResource)[0] || "";
405
+ const globalOptionKey = resolveArgKey(globalOption, ctx.name);
406
+ resource[globalOptionKey] = optionResource[localeStr] || optionResource[DEFAULT_LOCALE] || Object.values(optionResource)[0] || "";
407
407
  }
408
- adapter.setResource(localeStr$1, Object.assign(Object.create(null), adapter.getResource(localeStr$1), resource));
408
+ adapter.setResource(localeStr, Object.assign(Object.create(null), adapter.getResource(localeStr), resource));
409
409
  return loaded;
410
410
  }
411
411
  return {
@@ -416,7 +416,7 @@ function i18n(options = {}) {
416
416
  };
417
417
  },
418
418
  onExtension: async (ctx, cmd) => {
419
- const i18n$1 = ctx.extensions[pluginId];
419
+ const i18n = ctx.extensions[pluginId];
420
420
  const defaultCommandResource = Object.entries(ctx.args).map(([key, schema]) => [key, schema.description || ""]).reduce((res, [key, value]) => {
421
421
  res[resolveArgKey(key, ctx.name)] = value;
422
422
  return res;
@@ -424,7 +424,7 @@ function i18n(options = {}) {
424
424
  defaultCommandResource[resolveKey("description", ctx.name)] = cmd.description || "";
425
425
  defaultCommandResource[resolveKey("examples", ctx.name)] = await resolveExamples(ctx, cmd.examples);
426
426
  adapter.setResource(DEFAULT_LOCALE, defaultCommandResource);
427
- await i18n$1.loadResource(localeStr, ctx, cmd);
427
+ await i18n.loadResource(localeStr, ctx, cmd);
428
428
  }
429
429
  });
430
430
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin-i18n",
3
3
  "description": "internationalization plugin for gunshi",
4
- "version": "0.27.4",
4
+ "version": "0.27.6",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@gunshi/plugin": "0.27.4"
56
+ "@gunshi/plugin": "0.27.6"
57
57
  },
58
58
  "peerDependencies": {
59
- "@gunshi/plugin-global": "0.27.4"
59
+ "@gunshi/plugin-global": "0.27.6"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@gunshi/plugin-global": {
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "devDependencies": {
67
67
  "@intlify/core": "next",
68
- "deno": "^2.5.6",
68
+ "deno": "^2.6.3",
69
69
  "jsr": "^0.13.5",
70
70
  "jsr-exports-lint": "^0.4.1",
71
71
  "messageformat": "4.0.0",
@@ -73,12 +73,12 @@
73
73
  "tsdown": "0.15.12",
74
74
  "typedoc": "^0.28.15",
75
75
  "typedoc-plugin-markdown": "^4.9.0",
76
- "@gunshi/bone": "0.27.4",
77
- "@gunshi/plugin-global": "0.27.4",
78
- "@gunshi/plugin-renderer": "0.27.4",
79
- "@gunshi/resources": "0.27.4",
80
- "@gunshi/shared": "0.27.4",
81
- "gunshi": "0.27.4"
76
+ "@gunshi/bone": "0.27.6",
77
+ "@gunshi/plugin-global": "0.27.6",
78
+ "@gunshi/resources": "0.27.6",
79
+ "@gunshi/plugin-renderer": "0.27.6",
80
+ "@gunshi/shared": "0.27.6",
81
+ "gunshi": "0.27.6"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "tsdown",