intor-translator 1.4.0 → 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 +0 -2
- package/dist/index.cjs +13 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
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
|
|
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,7 +1,27 @@
|
|
|
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[];
|
|
19
|
+
/**
|
|
20
|
+
* A recursive message tree object.
|
|
21
|
+
*
|
|
22
|
+
* Represents the root message structure for a single locale
|
|
23
|
+
* (i.e. the value of `LocaleMessages[locale]`).
|
|
24
|
+
*/
|
|
5
25
|
interface MessageObject {
|
|
6
26
|
[key: string]: MessageValue;
|
|
7
27
|
}
|
|
@@ -409,11 +429,12 @@ type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
|
|
|
409
429
|
type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
|
|
410
430
|
hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
|
|
411
431
|
t: <Result = string>(key?: K, replacements?: Replacement) => Result;
|
|
432
|
+
tRaw: (key?: K, replacements?: Replacement) => MessageValue$1 | undefined;
|
|
412
433
|
};
|
|
413
434
|
|
|
414
435
|
declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
|
|
415
436
|
constructor(options: ScopeTranslatorOptions<M>);
|
|
416
|
-
/** Create a scoped translator with a prefix key
|
|
437
|
+
/** Create a scoped translator with a prefix key for resolving nested message paths. */
|
|
417
438
|
scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
|
|
418
439
|
}
|
|
419
440
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
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[];
|
|
19
|
+
/**
|
|
20
|
+
* A recursive message tree object.
|
|
21
|
+
*
|
|
22
|
+
* Represents the root message structure for a single locale
|
|
23
|
+
* (i.e. the value of `LocaleMessages[locale]`).
|
|
24
|
+
*/
|
|
5
25
|
interface MessageObject {
|
|
6
26
|
[key: string]: MessageValue;
|
|
7
27
|
}
|
|
@@ -409,11 +429,12 @@ type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
|
|
|
409
429
|
type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
|
|
410
430
|
hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
|
|
411
431
|
t: <Result = string>(key?: K, replacements?: Replacement) => Result;
|
|
432
|
+
tRaw: (key?: K, replacements?: Replacement) => MessageValue$1 | undefined;
|
|
412
433
|
};
|
|
413
434
|
|
|
414
435
|
declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
|
|
415
436
|
constructor(options: ScopeTranslatorOptions<M>);
|
|
416
|
-
/** Create a scoped translator with a prefix key
|
|
437
|
+
/** Create a scoped translator with a prefix key for resolving nested message paths. */
|
|
417
438
|
scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
|
|
418
439
|
}
|
|
419
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
|
|
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
|
}
|