@sheet-i18n/react-client 1.0.9 → 1.0.11
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 +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ __export(src_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
44
|
|
|
45
45
|
// src/createI18nContext.tsx
|
|
46
|
-
var
|
|
46
|
+
var import_shared_utils3 = require("@sheet-i18n/shared-utils");
|
|
47
47
|
var import_react_core = require("@sheet-i18n/react-core");
|
|
48
48
|
|
|
49
49
|
// src/IntlProvider.tsx
|
|
@@ -163,6 +163,7 @@ var IntlInstanceCache = class _IntlInstanceCache {
|
|
|
163
163
|
var intlInstanceCache = IntlInstanceCache.init();
|
|
164
164
|
|
|
165
165
|
// src/Service/TranslationService.ts
|
|
166
|
+
var import_shared_utils2 = require("@sheet-i18n/shared-utils");
|
|
166
167
|
var TranslationService = class {
|
|
167
168
|
constructor(intlInstance) {
|
|
168
169
|
this.intlInstance = intlInstance;
|
|
@@ -187,6 +188,9 @@ var TranslationService = class {
|
|
|
187
188
|
findTargetTranslation(id, $tParams) {
|
|
188
189
|
var _a, _b, _c, _d, _e;
|
|
189
190
|
const targetTranslation = (_b = (_a = this == null ? void 0 : this.intlInstance) == null ? void 0 : _a.messages) == null ? void 0 : _b[id];
|
|
191
|
+
if (import_shared_utils2.validator.isNullish(targetTranslation)) {
|
|
192
|
+
return id;
|
|
193
|
+
}
|
|
190
194
|
if (typeof targetTranslation === "string" && targetTranslation.trim() === "") {
|
|
191
195
|
return "";
|
|
192
196
|
}
|
|
@@ -276,7 +280,7 @@ function getTranslation({
|
|
|
276
280
|
// src/createI18nContext.tsx
|
|
277
281
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
278
282
|
function createI18nContext(i18nStore) {
|
|
279
|
-
if (
|
|
283
|
+
if (import_shared_utils3.validator.isNullish(i18nStore)) {
|
|
280
284
|
throw new InvalidI18nContextStateError(
|
|
281
285
|
"\u26A0\uFE0F no i18nStore provided. To use createI18nContext, you must provide an i18nStore as a parameter"
|
|
282
286
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
21
|
|
|
22
22
|
// src/createI18nContext.tsx
|
|
23
|
-
import { validator as
|
|
23
|
+
import { validator as validator3 } from "@sheet-i18n/shared-utils";
|
|
24
24
|
import { I18nStore } from "@sheet-i18n/react-core";
|
|
25
25
|
|
|
26
26
|
// src/IntlProvider.tsx
|
|
@@ -140,6 +140,7 @@ var IntlInstanceCache = class _IntlInstanceCache {
|
|
|
140
140
|
var intlInstanceCache = IntlInstanceCache.init();
|
|
141
141
|
|
|
142
142
|
// src/Service/TranslationService.ts
|
|
143
|
+
import { validator as validator2 } from "@sheet-i18n/shared-utils";
|
|
143
144
|
var TranslationService = class {
|
|
144
145
|
constructor(intlInstance) {
|
|
145
146
|
this.intlInstance = intlInstance;
|
|
@@ -164,6 +165,9 @@ var TranslationService = class {
|
|
|
164
165
|
findTargetTranslation(id, $tParams) {
|
|
165
166
|
var _a, _b, _c, _d, _e;
|
|
166
167
|
const targetTranslation = (_b = (_a = this == null ? void 0 : this.intlInstance) == null ? void 0 : _a.messages) == null ? void 0 : _b[id];
|
|
168
|
+
if (validator2.isNullish(targetTranslation)) {
|
|
169
|
+
return id;
|
|
170
|
+
}
|
|
167
171
|
if (typeof targetTranslation === "string" && targetTranslation.trim() === "") {
|
|
168
172
|
return "";
|
|
169
173
|
}
|
|
@@ -253,7 +257,7 @@ function getTranslation({
|
|
|
253
257
|
// src/createI18nContext.tsx
|
|
254
258
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
255
259
|
function createI18nContext(i18nStore) {
|
|
256
|
-
if (
|
|
260
|
+
if (validator3.isNullish(i18nStore)) {
|
|
257
261
|
throw new InvalidI18nContextStateError(
|
|
258
262
|
"\u26A0\uFE0F no i18nStore provided. To use createI18nContext, you must provide an i18nStore as a parameter"
|
|
259
263
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheet-i18n/react-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "a client package for react modules used by sheet-i18n",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"react": "^18.2.0",
|
|
29
29
|
"react-intl": "^7.0.4",
|
|
30
|
-
"@sheet-i18n/
|
|
31
|
-
"@sheet-i18n/
|
|
32
|
-
"@sheet-i18n/react-core": "1.0.
|
|
30
|
+
"@sheet-i18n/shared-utils": "1.3.10",
|
|
31
|
+
"@sheet-i18n/errors": "1.3.10",
|
|
32
|
+
"@sheet-i18n/react-core": "1.0.8"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^19.0.2",
|
|
36
36
|
"@types/react-dom": "^19.0.2",
|
|
37
|
-
"@sheet-i18n/typescript-config": "1.3.
|
|
37
|
+
"@sheet-i18n/typescript-config": "1.3.10"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|