intor-translator 1.0.7 → 1.0.8

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.cjs CHANGED
@@ -297,29 +297,29 @@ var getFullKey = (preKey = "", key = "") => {
297
297
  var ScopeTranslator = class extends CoreTranslator {
298
298
  constructor(options) {
299
299
  super(options);
300
- this.scoped = (preKey) => {
301
- return {
302
- hasKey: (key, targetLocale) => {
303
- const fullKey = getFullKey(preKey, key);
304
- return hasKey({
305
- messagesRef: this.messagesRef,
306
- localeRef: this.localeRef,
307
- key: fullKey,
308
- targetLocale
309
- });
310
- },
311
- t: (key, replacements) => {
312
- const fullKey = getFullKey(preKey, key);
313
- return translate({
314
- messagesRef: this.messagesRef,
315
- localeRef: this.localeRef,
316
- isLoadingRef: this.isLoadingRef,
317
- translateConfig: this.options,
318
- key: fullKey,
319
- replacements
320
- });
321
- }
322
- };
300
+ }
301
+ scoped(preKey) {
302
+ return {
303
+ hasKey: (key, targetLocale) => {
304
+ const fullKey = getFullKey(preKey, key);
305
+ return hasKey({
306
+ messagesRef: this.messagesRef,
307
+ localeRef: this.localeRef,
308
+ key: fullKey,
309
+ targetLocale
310
+ });
311
+ },
312
+ t: (key, replacements) => {
313
+ const fullKey = getFullKey(preKey, key);
314
+ return translate({
315
+ messagesRef: this.messagesRef,
316
+ localeRef: this.localeRef,
317
+ isLoadingRef: this.isLoadingRef,
318
+ translateConfig: this.options,
319
+ key: fullKey,
320
+ replacements
321
+ });
322
+ }
323
323
  };
324
324
  }
325
325
  };
package/dist/index.d.cts CHANGED
@@ -386,9 +386,13 @@ declare class CoreTranslator<M extends LocaleNamespaceMessages = never> extends
386
386
 
387
387
  declare class ScopeTranslator<M extends LocaleNamespaceMessages = never> extends CoreTranslator<M> {
388
388
  constructor(options?: CoreTranslatorOptions<M>);
389
- scoped: <K extends NodeKeys<UnionLocaleMessages<M>> & string, ScopedKeys extends ScopedLeafKeys<M, K> & string>(preKey: K) => {
390
- hasKey: (key?: ScopedKeys | undefined, targetLocale?: string) => boolean;
391
- t: (key?: ScopedKeys | undefined, replacements?: Replacement | RichReplacement) => string;
389
+ scoped<K extends NodeKeys<UnionLocaleMessages<M>> & string>(preKey: K): {
390
+ hasKey: (key?: ScopedLeafKeys<M, K> & string, targetLocale?: string) => boolean;
391
+ t: (key?: ScopedLeafKeys<M, K> & string, replacements?: Replacement | RichReplacement) => string;
392
+ };
393
+ scoped(): {
394
+ hasKey: (key?: UnionLocaleLeafKeys<M> & string, targetLocale?: string) => boolean;
395
+ t: (key?: UnionLocaleLeafKeys<M> & string, replacements?: Replacement | RichReplacement) => string;
392
396
  };
393
397
  }
394
398
 
package/dist/index.d.ts CHANGED
@@ -386,9 +386,13 @@ declare class CoreTranslator<M extends LocaleNamespaceMessages = never> extends
386
386
 
387
387
  declare class ScopeTranslator<M extends LocaleNamespaceMessages = never> extends CoreTranslator<M> {
388
388
  constructor(options?: CoreTranslatorOptions<M>);
389
- scoped: <K extends NodeKeys<UnionLocaleMessages<M>> & string, ScopedKeys extends ScopedLeafKeys<M, K> & string>(preKey: K) => {
390
- hasKey: (key?: ScopedKeys | undefined, targetLocale?: string) => boolean;
391
- t: (key?: ScopedKeys | undefined, replacements?: Replacement | RichReplacement) => string;
389
+ scoped<K extends NodeKeys<UnionLocaleMessages<M>> & string>(preKey: K): {
390
+ hasKey: (key?: ScopedLeafKeys<M, K> & string, targetLocale?: string) => boolean;
391
+ t: (key?: ScopedLeafKeys<M, K> & string, replacements?: Replacement | RichReplacement) => string;
392
+ };
393
+ scoped(): {
394
+ hasKey: (key?: UnionLocaleLeafKeys<M> & string, targetLocale?: string) => boolean;
395
+ t: (key?: UnionLocaleLeafKeys<M> & string, replacements?: Replacement | RichReplacement) => string;
392
396
  };
393
397
  }
394
398
 
package/dist/index.js CHANGED
@@ -295,29 +295,29 @@ var getFullKey = (preKey = "", key = "") => {
295
295
  var ScopeTranslator = class extends CoreTranslator {
296
296
  constructor(options) {
297
297
  super(options);
298
- this.scoped = (preKey) => {
299
- return {
300
- hasKey: (key, targetLocale) => {
301
- const fullKey = getFullKey(preKey, key);
302
- return hasKey({
303
- messagesRef: this.messagesRef,
304
- localeRef: this.localeRef,
305
- key: fullKey,
306
- targetLocale
307
- });
308
- },
309
- t: (key, replacements) => {
310
- const fullKey = getFullKey(preKey, key);
311
- return translate({
312
- messagesRef: this.messagesRef,
313
- localeRef: this.localeRef,
314
- isLoadingRef: this.isLoadingRef,
315
- translateConfig: this.options,
316
- key: fullKey,
317
- replacements
318
- });
319
- }
320
- };
298
+ }
299
+ scoped(preKey) {
300
+ return {
301
+ hasKey: (key, targetLocale) => {
302
+ const fullKey = getFullKey(preKey, key);
303
+ return hasKey({
304
+ messagesRef: this.messagesRef,
305
+ localeRef: this.localeRef,
306
+ key: fullKey,
307
+ targetLocale
308
+ });
309
+ },
310
+ t: (key, replacements) => {
311
+ const fullKey = getFullKey(preKey, key);
312
+ return translate({
313
+ messagesRef: this.messagesRef,
314
+ localeRef: this.localeRef,
315
+ isLoadingRef: this.isLoadingRef,
316
+ translateConfig: this.options,
317
+ key: fullKey,
318
+ replacements
319
+ });
320
+ }
321
321
  };
322
322
  }
323
323
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor-translator",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A type safe translator that knows what to say and how to handle the rest. Supports custom messages, rich replacements, and async loading.",
5
5
  "author": "Yiming Liao",
6
6
  "license": "MIT",