@sheet-i18n/react 1.7.4 → 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/README.md CHANGED
@@ -8,7 +8,7 @@ This package provides tools to handle translations in React applications using c
8
8
 
9
9
  ## ✨ Package Introduction
10
10
 
11
- - **`I18nStore`**: _Core Store Creation Class_ for managing translation data.
11
+ - **`I18nStore`**: _Core Store Creation Class_ from `@sheet-i18n/core` for managing translation data.
12
12
  - **`createI18nContext`**: _React Context_ to generate providers and hooks for translation.
13
13
  - **`IntlProvider`**: _React Translation Provider_ for managing current locale.
14
14
  - **`useTranslation`**: _Client Side Translation Hook_ for easy access to translation messages on the client side.
@@ -52,7 +52,7 @@ this store will be used as a core translations module.
52
52
  import en from './en.json';
53
53
  import ko from './ko.json';
54
54
 
55
- import { I18nStore } from '@sheet-i18n/react';
55
+ import { I18nStore } from '@sheet-i18n/core';
56
56
 
57
57
  export const i18nStore = new I18nStore({
58
58
  supportedLocales: ['ko', 'en'],
@@ -127,6 +127,8 @@ const YourComponent = () => {
127
127
 
128
128
  The `I18nStore` manages translation states, ensuring consistency across locales.
129
129
 
130
+ Import it from `@sheet-i18n/core`, then pass the created store to `createI18nContext` from `@sheet-i18n/react`.
131
+
130
132
  #### Parameters:
131
133
 
132
134
  ### 🧠 I18nStore Configuration Options
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
- const messageId = ruleFn(values, {});
278
- const translationValue = translationService.translate(messageId, values);
279
- const interpolatedTranslationValue = translationService.interpolatePlaceholders(translationValue, values);
280
- return interpolatedTranslationValue;
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
- const messageId = ruleFn(values, {});
257
- const translationValue = translationService.translate(messageId, values);
258
- const interpolatedTranslationValue = translationService.interpolatePlaceholders(translationValue, values);
259
- return interpolatedTranslationValue;
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.4",
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",
@@ -13,11 +13,6 @@
13
13
  "types": "./dist/index.d.mts",
14
14
  "require": "./dist/index.js",
15
15
  "import": "./dist/index.mjs"
16
- },
17
- "./core": {
18
- "types": "./dist/core.d.mts",
19
- "require": "./dist/core.js",
20
- "import": "./dist/core.mjs"
21
16
  }
22
17
  },
23
18
  "publishConfig": {
@@ -38,15 +33,15 @@
38
33
  "@types/react": "^19.0.2",
39
34
  "@types/react-dom": "^19.0.2",
40
35
  "react": "^19.0.0",
41
- "@sheet-i18n/typescript-config": "1.8.2"
36
+ "@sheet-i18n/typescript-config": "1.8.3"
42
37
  },
43
38
  "dependencies": {
44
39
  "react-intl": "^7.0.4",
45
- "@sheet-i18n/core": "1.7.0",
46
- "@sheet-i18n/shared-service": "0.2.0",
47
- "@sheet-i18n/typescript": "0.4.0",
48
- "@sheet-i18n/errors": "1.8.2",
49
- "@sheet-i18n/shared-utils": "1.8.3"
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"
50
45
  },
51
46
  "peerDependencies": {
52
47
  "react": "^18 || ^19 || ^20 || ^21",
package/dist/core.d.mts DELETED
@@ -1 +0,0 @@
1
- export * from '@sheet-i18n/core';
package/dist/core.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '@sheet-i18n/core';
package/dist/core.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
-
17
- // src/core.ts
18
- var core_exports = {};
19
- module.exports = __toCommonJS(core_exports);
20
- __reExport(core_exports, require("@sheet-i18n/core"), module.exports);
21
- // Annotate the CommonJS export names for ESM import in node:
22
- 0 && (module.exports = {
23
- ...require("@sheet-i18n/core")
24
- });
package/dist/core.mjs DELETED
@@ -1,2 +0,0 @@
1
- // src/core.ts
2
- export * from "@sheet-i18n/core";