intor-translator 1.4.1 → 1.4.2

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/README.md CHANGED
@@ -17,8 +17,6 @@ Easy to use, modular at its core, and fully extensible.
17
17
 
18
18
  </div>
19
19
 
20
- > Structured 󠁯•󠁏 Predictable 󠁯•󠁏 Beautifully simple
21
-
22
20
  ## Features
23
21
 
24
22
  - 🔧 **Modular Pipeline** – A pluggable, hook-driven flow for any translation logic.
package/dist/index.cjs CHANGED
@@ -340,7 +340,7 @@ var ScopeTranslator = class extends CoreTranslator {
340
340
  constructor(options) {
341
341
  super(options);
342
342
  }
343
- /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
343
+ /** Create a scoped translator with a prefix key for resolving nested message paths. */
344
344
  scoped(preKey) {
345
345
  return {
346
346
  hasKey: (key, targetLocale) => {
@@ -363,6 +363,18 @@ var ScopeTranslator = class extends CoreTranslator {
363
363
  key: fullKey,
364
364
  replacements
365
365
  });
366
+ },
367
+ tRaw: (key, replacements) => {
368
+ const fullKey = getFullKey(preKey, key);
369
+ return translateRaw({
370
+ hooks: this.hooks,
371
+ messages: this._messages,
372
+ locale: this._locale,
373
+ isLoading: this._isLoading,
374
+ translateConfig: this.translateConfig,
375
+ key: fullKey,
376
+ replacements
377
+ });
366
378
  }
367
379
  };
368
380
  }
package/dist/index.d.cts CHANGED
@@ -1,5 +1,19 @@
1
1
  import { RuraHook } from 'rura';
2
2
 
3
+ type MessagePrimitive$1 = string | number | boolean | null;
4
+ type MessageArray$1 = readonly MessageValue$1[];
5
+ /**
6
+ * A recursive message tree object.
7
+ *
8
+ * Represents the root message structure for a single locale
9
+ * (i.e. the value of `LocaleMessages[locale]`).
10
+ */
11
+ interface MessageObject$1 {
12
+ [key: string]: MessageValue$1;
13
+ }
14
+ /** A message value in the locale message tree. */
15
+ type MessageValue$1 = MessagePrimitive$1 | MessageObject$1 | MessageArray$1;
16
+
3
17
  type MessagePrimitive = string | number | boolean | null;
4
18
  type MessageArray = readonly MessageValue[];
5
19
  /**
@@ -415,11 +429,12 @@ type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
415
429
  type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
416
430
  hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
417
431
  t: <Result = string>(key?: K, replacements?: Replacement) => Result;
432
+ tRaw: (key?: K, replacements?: Replacement) => MessageValue$1 | undefined;
418
433
  };
419
434
 
420
435
  declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
421
436
  constructor(options: ScopeTranslatorOptions<M>);
422
- /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
437
+ /** Create a scoped translator with a prefix key for resolving nested message paths. */
423
438
  scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
424
439
  }
425
440
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  import { RuraHook } from 'rura';
2
2
 
3
+ type MessagePrimitive$1 = string | number | boolean | null;
4
+ type MessageArray$1 = readonly MessageValue$1[];
5
+ /**
6
+ * A recursive message tree object.
7
+ *
8
+ * Represents the root message structure for a single locale
9
+ * (i.e. the value of `LocaleMessages[locale]`).
10
+ */
11
+ interface MessageObject$1 {
12
+ [key: string]: MessageValue$1;
13
+ }
14
+ /** A message value in the locale message tree. */
15
+ type MessageValue$1 = MessagePrimitive$1 | MessageObject$1 | MessageArray$1;
16
+
3
17
  type MessagePrimitive = string | number | boolean | null;
4
18
  type MessageArray = readonly MessageValue[];
5
19
  /**
@@ -415,11 +429,12 @@ type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
415
429
  type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
416
430
  hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
417
431
  t: <Result = string>(key?: K, replacements?: Replacement) => Result;
432
+ tRaw: (key?: K, replacements?: Replacement) => MessageValue$1 | undefined;
418
433
  };
419
434
 
420
435
  declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
421
436
  constructor(options: ScopeTranslatorOptions<M>);
422
- /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
437
+ /** Create a scoped translator with a prefix key for resolving nested message paths. */
423
438
  scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
424
439
  }
425
440
 
package/dist/index.js CHANGED
@@ -338,7 +338,7 @@ var ScopeTranslator = class extends CoreTranslator {
338
338
  constructor(options) {
339
339
  super(options);
340
340
  }
341
- /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
341
+ /** Create a scoped translator with a prefix key for resolving nested message paths. */
342
342
  scoped(preKey) {
343
343
  return {
344
344
  hasKey: (key, targetLocale) => {
@@ -361,6 +361,18 @@ var ScopeTranslator = class extends CoreTranslator {
361
361
  key: fullKey,
362
362
  replacements
363
363
  });
364
+ },
365
+ tRaw: (key, replacements) => {
366
+ const fullKey = getFullKey(preKey, key);
367
+ return translateRaw({
368
+ hooks: this.hooks,
369
+ messages: this._messages,
370
+ locale: this._locale,
371
+ isLoading: this._isLoading,
372
+ translateConfig: this.translateConfig,
373
+ key: fullKey,
374
+ replacements
375
+ });
364
376
  }
365
377
  };
366
378
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor-translator",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "🤖 A modern, type-safe i18n engine.",
5
5
  "author": {
6
6
  "name": "Yiming Liao",