@sheet-i18n/react 1.7.5 → 1.7.6
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.js +12 -4
- package/dist/index.mjs +12 -4
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -274,10 +274,18 @@ function useTranslation({
|
|
|
274
274
|
t.rule = (ruleKey, values) => {
|
|
275
275
|
const ruleFn = rules == null ? void 0 : rules[ruleKey];
|
|
276
276
|
if (!ruleFn) return ruleKey;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
try {
|
|
278
|
+
const messageId = ruleFn(values, {});
|
|
279
|
+
if (messageId === null || messageId === void 0) {
|
|
280
|
+
return String(ruleKey);
|
|
281
|
+
}
|
|
282
|
+
const translationValue = translationService.translate(messageId, values);
|
|
283
|
+
const interpolatedTranslationValue = translationService.interpolatePlaceholders(translationValue, values);
|
|
284
|
+
return interpolatedTranslationValue;
|
|
285
|
+
} catch (error) {
|
|
286
|
+
console.error(`[sheet-i18n] t.rule("${String(ruleKey)}") failed.`, error);
|
|
287
|
+
return String(ruleKey);
|
|
288
|
+
}
|
|
281
289
|
};
|
|
282
290
|
return { t };
|
|
283
291
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -253,10 +253,18 @@ function useTranslation({
|
|
|
253
253
|
t.rule = (ruleKey, values) => {
|
|
254
254
|
const ruleFn = rules == null ? void 0 : rules[ruleKey];
|
|
255
255
|
if (!ruleFn) return ruleKey;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
try {
|
|
257
|
+
const messageId = ruleFn(values, {});
|
|
258
|
+
if (messageId === null || messageId === void 0) {
|
|
259
|
+
return String(ruleKey);
|
|
260
|
+
}
|
|
261
|
+
const translationValue = translationService.translate(messageId, values);
|
|
262
|
+
const interpolatedTranslationValue = translationService.interpolatePlaceholders(translationValue, values);
|
|
263
|
+
return interpolatedTranslationValue;
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error(`[sheet-i18n] t.rule("${String(ruleKey)}") failed.`, error);
|
|
266
|
+
return String(ruleKey);
|
|
267
|
+
}
|
|
260
268
|
};
|
|
261
269
|
return { t };
|
|
262
270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheet-i18n/react",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"description": "i18n client logic based on react",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"@types/react": "^19.0.2",
|
|
34
34
|
"@types/react-dom": "^19.0.2",
|
|
35
35
|
"react": "^19.0.0",
|
|
36
|
-
"@sheet-i18n/typescript-config": "1.8.
|
|
36
|
+
"@sheet-i18n/typescript-config": "1.8.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"react-intl": "^7.0.4",
|
|
40
|
-
"@sheet-i18n/
|
|
41
|
-
"@sheet-i18n/
|
|
42
|
-
"@sheet-i18n/
|
|
43
|
-
"@sheet-i18n/
|
|
44
|
-
"@sheet-i18n/shared-utils": "1.8.
|
|
40
|
+
"@sheet-i18n/core": "1.7.1",
|
|
41
|
+
"@sheet-i18n/typescript": "0.4.1",
|
|
42
|
+
"@sheet-i18n/errors": "1.8.3",
|
|
43
|
+
"@sheet-i18n/shared-service": "0.2.1",
|
|
44
|
+
"@sheet-i18n/shared-utils": "1.8.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18 || ^19 || ^20 || ^21",
|