intor-translator 1.0.13 → 1.0.14

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
@@ -194,11 +194,11 @@ var translate = ({
194
194
  return loadingMessage;
195
195
  }
196
196
  }
197
- if (!message) {
197
+ if (message === void 0 || message === null) {
198
198
  if (onMissing) {
199
199
  return onMissing({ key, locale, replacements });
200
200
  }
201
- if (placeholder) {
201
+ if (placeholder !== void 0 && placeholder !== null) {
202
202
  return placeholder;
203
203
  }
204
204
  return key;
package/dist/index.d.cts CHANGED
@@ -418,24 +418,4 @@ declare class ScopeTranslator<M = unknown> extends CoreTranslator<M> {
418
418
  scoped(): TranslatorMethods<M>;
419
419
  }
420
420
 
421
- /**
422
- * Generic translate function type.
423
- *
424
- * Represents the shape of a `t()` function that supports typed keys and optional replacements.
425
- *
426
- * @template M - The shape of the messages object (e.g., typeof messages)
427
- * @template Result - The expected return type (usually string, but can be JSX or others)
428
- */
429
- type TranslateFunction = <M, Result = string>(key: InferTranslatorKey<M>, replacements?: Replacement | RichReplacement) => Result;
430
- /**
431
- * Generic hasKey function type.
432
- *
433
- * Represents a function that checks if a given key exists in a message set,
434
- * optionally for a specific locale.
435
- *
436
- * @template M - The shape of the messages object
437
- * @template Result - The return value (default is boolean, override if needed)
438
- */
439
- type HasKeyFunction = <M, Result = boolean>(key: InferTranslatorKey<M>, targetLocale?: LocaleKey<M>) => Result;
440
-
441
- export { type FallbackLocalesMap, type FormatMessage, type HasKeyFunction, type InferTranslatorKey, type IsLoadingRef, type LeafKeys, type Locale, type LocaleKey, type LocaleNamespaceMessages, type LocaleRef, type Message, type MessageRecord, type MessagesRef, type Namespace, type NamespaceMessages, type NestedMessage, type NodeKeys, type OnLoading, type OnMissing, type Replacement, type RichReplacement, type ScopedLeafKeys, type StrictLocaleKey, type TranslateConfig, type TranslateContext, type TranslateFunction, type TranslateHandlers, ScopeTranslator as Translator, type UnionLocaleLeafKeys, type UnionLocaleMessages };
421
+ export { type FallbackLocalesMap, type FormatMessage, type InferTranslatorKey, type IsLoadingRef, type LeafKeys, type Locale, type LocaleKey, type LocaleNamespaceMessages, type LocaleRef, type Message, type MessageRecord, type MessagesRef, type Namespace, type NamespaceMessages, type NestedMessage, type NodeKeys, type OnLoading, type OnMissing, type Replacement, type RichReplacement, type ScopedLeafKeys, type StrictLocaleKey, type TranslateConfig, type TranslateContext, type TranslateHandlers, ScopeTranslator as Translator, type UnionLocaleLeafKeys, type UnionLocaleMessages };
package/dist/index.d.ts CHANGED
@@ -418,24 +418,4 @@ declare class ScopeTranslator<M = unknown> extends CoreTranslator<M> {
418
418
  scoped(): TranslatorMethods<M>;
419
419
  }
420
420
 
421
- /**
422
- * Generic translate function type.
423
- *
424
- * Represents the shape of a `t()` function that supports typed keys and optional replacements.
425
- *
426
- * @template M - The shape of the messages object (e.g., typeof messages)
427
- * @template Result - The expected return type (usually string, but can be JSX or others)
428
- */
429
- type TranslateFunction = <M, Result = string>(key: InferTranslatorKey<M>, replacements?: Replacement | RichReplacement) => Result;
430
- /**
431
- * Generic hasKey function type.
432
- *
433
- * Represents a function that checks if a given key exists in a message set,
434
- * optionally for a specific locale.
435
- *
436
- * @template M - The shape of the messages object
437
- * @template Result - The return value (default is boolean, override if needed)
438
- */
439
- type HasKeyFunction = <M, Result = boolean>(key: InferTranslatorKey<M>, targetLocale?: LocaleKey<M>) => Result;
440
-
441
- export { type FallbackLocalesMap, type FormatMessage, type HasKeyFunction, type InferTranslatorKey, type IsLoadingRef, type LeafKeys, type Locale, type LocaleKey, type LocaleNamespaceMessages, type LocaleRef, type Message, type MessageRecord, type MessagesRef, type Namespace, type NamespaceMessages, type NestedMessage, type NodeKeys, type OnLoading, type OnMissing, type Replacement, type RichReplacement, type ScopedLeafKeys, type StrictLocaleKey, type TranslateConfig, type TranslateContext, type TranslateFunction, type TranslateHandlers, ScopeTranslator as Translator, type UnionLocaleLeafKeys, type UnionLocaleMessages };
421
+ export { type FallbackLocalesMap, type FormatMessage, type InferTranslatorKey, type IsLoadingRef, type LeafKeys, type Locale, type LocaleKey, type LocaleNamespaceMessages, type LocaleRef, type Message, type MessageRecord, type MessagesRef, type Namespace, type NamespaceMessages, type NestedMessage, type NodeKeys, type OnLoading, type OnMissing, type Replacement, type RichReplacement, type ScopedLeafKeys, type StrictLocaleKey, type TranslateConfig, type TranslateContext, type TranslateHandlers, ScopeTranslator as Translator, type UnionLocaleLeafKeys, type UnionLocaleMessages };
package/dist/index.js CHANGED
@@ -192,11 +192,11 @@ var translate = ({
192
192
  return loadingMessage;
193
193
  }
194
194
  }
195
- if (!message) {
195
+ if (message === void 0 || message === null) {
196
196
  if (onMissing) {
197
197
  return onMissing({ key, locale, replacements });
198
198
  }
199
- if (placeholder) {
199
+ if (placeholder !== void 0 && placeholder !== null) {
200
200
  return placeholder;
201
201
  }
202
202
  return key;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor-translator",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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",