i18n-keyless-react 1.17.7 → 1.18.0
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.
|
@@ -5,7 +5,7 @@ export interface I18nKeylessTextProps {
|
|
|
5
5
|
* The `children` prop must be a string.
|
|
6
6
|
* It's the text to translate from your primary language.
|
|
7
7
|
*/
|
|
8
|
-
children: string;
|
|
8
|
+
children: string | React.ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* The keys to replace in the text.
|
|
11
11
|
* It's an object where the key is the placeholder and the value is the replacement.
|
package/dist/I18nKeylessText.js
CHANGED
|
@@ -7,15 +7,16 @@ const warnAboutWhitespace = (text) => {
|
|
|
7
7
|
"This may cause inconsistencies in translations. Consider trimming the text.");
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
export const I18nKeylessText = ({ children, replace, context, debug = false, forceTemporary
|
|
10
|
+
export const I18nKeylessText = ({ children, replace, context, debug = false, forceTemporary }) => {
|
|
11
11
|
const translations = useI18nKeyless((store) => store.translations);
|
|
12
12
|
const currentLanguage = useI18nKeyless((store) => store.currentLanguage);
|
|
13
13
|
const config = useI18nKeyless((store) => store.config);
|
|
14
14
|
// Trim the source text immediately
|
|
15
|
-
const
|
|
15
|
+
const rawText = Array.isArray(children) ? children.join("") : String(children ?? "");
|
|
16
|
+
const sourceText = rawText.trim();
|
|
16
17
|
useEffect(() => {
|
|
17
|
-
warnAboutWhitespace(
|
|
18
|
-
}, [
|
|
18
|
+
warnAboutWhitespace(rawText);
|
|
19
|
+
}, [rawText]);
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
getTranslation(sourceText, { context, debug, forceTemporary });
|
|
21
22
|
}, [sourceText, currentLanguage, context, debug, forceTemporary]);
|
|
@@ -44,7 +45,7 @@ export const I18nKeylessText = ({ children, replace, context, debug = false, for
|
|
|
44
45
|
finalText,
|
|
45
46
|
replace,
|
|
46
47
|
context,
|
|
47
|
-
forceTemporary
|
|
48
|
+
forceTemporary
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
return _jsx(React.Fragment, { children: finalText }, currentLanguage);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18n-keyless-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.18.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"postpublish": "rm -rf ./dist && rm *.tgz"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"i18n-keyless-core": "1.
|
|
27
|
+
"i18n-keyless-core": "1.18.0",
|
|
28
28
|
"zustand": "^5.0.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|