i18n-keyless-react 1.7.5 → 1.7.7

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.
@@ -2,30 +2,30 @@ import React from "react";
2
2
  import { TranslationOptions } from "i18n-keyless-core";
3
3
  export interface I18nKeylessTextProps {
4
4
  /**
5
- * children must be a string
6
- * it's the text to translate from your primary language
5
+ * The `children` prop must be a string.
6
+ * It's the text to translate from your primary language.
7
7
  */
8
8
  children: string;
9
9
  /**
10
- * the keys to replace in the text
11
- * it's an object where the key is the placeholder and the value is the replacement
12
- * example: { "{{name}}": "John" } will replace all the {{name}} in the text with "John"
13
- * RegEx is `key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))` so you can use use your own syntax
10
+ * The keys to replace in the text.
11
+ * It's an object where the key is the placeholder and the value is the replacement.
12
+ * Example: { "{{name}}": "John" } will replace all the {{name}} in the text with "John".
13
+ * RegEx is `key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))` so you can use use your own syntax.
14
14
  */
15
15
  replace?: Record<string, string>;
16
16
  /**
17
- * the context of the translation
18
- * it's useful for ambiguous translations, like "8 heures" in French could be "8 AM" or "8 hours"
17
+ * The context of the translation.
18
+ * It's useful for ambiguous translations, like "8 heures" in French could be "8 AM" or "8 hours".
19
19
  */
20
- context?: string;
20
+ context?: TranslationOptions["context"];
21
21
  /**
22
- * if true, some helpful logs will be displayed in the console
22
+ * If true, some helpful logs will be displayed in the console.
23
23
  */
24
- debug?: boolean;
24
+ debug?: TranslationOptions["debug"];
25
25
  /**
26
- * if true, the translation will be saved as temporary
27
- * it's useful if you want to use the translation in a different context
28
- * you can leave it there forever, or remove it once your translation is saved
26
+ * If the proposed translation from AI is not satisfactory,
27
+ * you can use this field to setup your own translation.
28
+ * You can leave it there forever, or remove it once your translation is saved.
29
29
  */
30
30
  forceTemporary?: TranslationOptions["forceTemporary"];
31
31
  }
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-react",
3
3
  "private": false,
4
- "version": "1.7.5",
4
+ "version": "1.7.7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
package/dist/store.js CHANGED
@@ -106,6 +106,10 @@ export const useI18nKeyless = create((set, get) => ({
106
106
  if (currentLanguage === config.languages.primary) {
107
107
  return text;
108
108
  }
109
+ const forceTemporary = options?.forceTemporary;
110
+ if (forceTemporary?.[currentLanguage]) {
111
+ get().translateKey(forceTemporary[currentLanguage], options);
112
+ }
109
113
  const context = options?.context;
110
114
  const translation = context ? get().translations[`${text}__${context}`] : get().translations[text];
111
115
  if (!translation) {
@@ -135,8 +139,9 @@ export const useI18nKeyless = create((set, get) => ({
135
139
  if (debug) {
136
140
  console.log("translateKey", key, context, debug);
137
141
  }
142
+ const forceTemporaryLang = options?.forceTemporary?.[get().currentLanguage];
138
143
  const translation = context ? get().translations[`${key}__${context}`] : get().translations[key];
139
- if (translation) {
144
+ if (translation && !forceTemporaryLang) {
140
145
  if (debug) {
141
146
  console.log("translation exists", `${key}__${context}`);
142
147
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-react",
3
3
  "private": false,
4
- "version": "1.7.5",
4
+ "version": "1.7.7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",