sheet-i18n 1.10.2 → 1.10.3
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 +65 -13
- package/dist/index.d.ts +2 -3
- package/dist/index.js +0 -17
- package/package.json +3 -17
- package/dist/importer/index.d.ts +0 -1
- package/dist/importer/index.js +0 -24
- package/dist/importer/index.mjs +0 -2
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -24
- package/dist/react/index.mjs +0 -2
package/README.md
CHANGED
|
@@ -15,19 +15,25 @@ It serves as a bridge between your translation data and your application, offeri
|
|
|
15
15
|
|
|
16
16
|
The `sheet-i18n` ecosystem is divided into three main packages:
|
|
17
17
|
|
|
18
|
-
-
|
|
18
|
+
- `@sheet-i18n/react`
|
|
19
19
|
- `@sheet-i18n/cli`
|
|
20
|
-
-
|
|
20
|
+
- `@sheet-i18n/importer`
|
|
21
21
|
|
|
22
22
|
### Installation
|
|
23
23
|
|
|
24
24
|
```shell
|
|
25
|
-
|
|
25
|
+
# React client
|
|
26
|
+
npm install @sheet-i18n/react
|
|
27
|
+
|
|
28
|
+
# CLI tool (dev dependency)
|
|
26
29
|
npm install @sheet-i18n/cli -D
|
|
30
|
+
|
|
31
|
+
# Optional: only if using the server-side Google Sheets importer
|
|
32
|
+
npm install @sheet-i18n/importer
|
|
27
33
|
```
|
|
28
34
|
|
|
29
35
|
<details open>
|
|
30
|
-
<summary><strong>⚛️ Frontend Translation Provider - sheet-i18n/react</strong></summary>
|
|
36
|
+
<summary><strong>⚛️ Frontend Translation Provider - @sheet-i18n/react</strong></summary>
|
|
31
37
|
|
|
32
38
|
### `@sheet-i18n/react`
|
|
33
39
|
|
|
@@ -561,11 +567,7 @@ export default function App() {
|
|
|
561
567
|
}
|
|
562
568
|
```
|
|
563
569
|
|
|
564
|
-
##
|
|
565
|
-
|
|
566
|
-
sheet-i18n provides advanced interpolation strategies for different rendering environments. These strategies ensure optimal performance and user experience across various deployment scenarios.
|
|
567
|
-
|
|
568
|
-
### 🖥️ Client-Side Rendering (CSR) Interpolation
|
|
570
|
+
## 🖥️ Persistent Locale Settings
|
|
569
571
|
|
|
570
572
|
For client-side applications, sheet-i18n offers `StorageBasedIntlProvider` with `LocaleStorageManager` to handle **persistent locale settings** and interpolation seamlessly.
|
|
571
573
|
|
|
@@ -797,6 +799,56 @@ const { t } = useTranslation('userSheet');
|
|
|
797
799
|
const translatedText = t.rule('ageRule', { age: 25 }); // 'You are an adult. Your age is 25'
|
|
798
800
|
```
|
|
799
801
|
|
|
802
|
+
## 🌐 Monorepo Support
|
|
803
|
+
|
|
804
|
+
### **Render Prop Support (Monorepo-Friendly)**
|
|
805
|
+
|
|
806
|
+
Both `StorageBasedIntlProvider` and `IntlProvider` accept either regular children
|
|
807
|
+
or a render function. When a function is provided, the current locale is injected
|
|
808
|
+
as the first argument. This is useful in monorepos where:
|
|
809
|
+
|
|
810
|
+
```text
|
|
811
|
+
┌───────────────┐ ┌───────────────────────┐
|
|
812
|
+
│ workspace app │ ───────> │ app i18n context │
|
|
813
|
+
└───────────────┘ │ (Store A) │
|
|
814
|
+
└───────────────────────┘
|
|
815
|
+
|
|
816
|
+
┌───────────────┐ ┌───────────────────────┐
|
|
817
|
+
│ packages/ui │ ───────> │ ui i18n context │
|
|
818
|
+
└───────────────┘ │ (Store B) │
|
|
819
|
+
└───────────────────────┘
|
|
820
|
+
|
|
821
|
+
locale bridge (A -> B)
|
|
822
|
+
|
|
823
|
+
The contexts stay separate (for example, different packages can point to
|
|
824
|
+
different sheets), while the current locale can still be bridged.
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
// packages/ui: export its own IntlProvider
|
|
829
|
+
export { IntlProvider as PackageUIIntlProvider } from './src/i18n/i18nContext';
|
|
830
|
+
|
|
831
|
+
// workspace: bridge the locale to the package provider
|
|
832
|
+
import { PackageUIIntlProvider } from '@packages/ui';
|
|
833
|
+
import {
|
|
834
|
+
localeStorageManager,
|
|
835
|
+
StorageBasedIntlProvider,
|
|
836
|
+
} from '@/i18n/i18nContext';
|
|
837
|
+
|
|
838
|
+
export default function LocaleProvider({ children }: PropsWithChildren) {
|
|
839
|
+
return (
|
|
840
|
+
<StorageBasedIntlProvider storageManager={localeStorageManager}>
|
|
841
|
+
// currentLocale: automatically injected
|
|
842
|
+
{(currentLocale) => (
|
|
843
|
+
<PackageUIIntlProvider currentLocale={currentLocale}>
|
|
844
|
+
{children}
|
|
845
|
+
</PackageUIIntlProvider>
|
|
846
|
+
)}
|
|
847
|
+
</StorageBasedIntlProvider>
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
```
|
|
851
|
+
|
|
800
852
|
</details>
|
|
801
853
|
|
|
802
854
|
---
|
|
@@ -1015,7 +1067,7 @@ When watch mode is started, the CLI will detect changes of "useTranslation" and
|
|
|
1015
1067
|
|
|
1016
1068
|
```tsx
|
|
1017
1069
|
//translationContext.tsx
|
|
1018
|
-
import { createI18nContext } from 'sheet-i18n/react';
|
|
1070
|
+
import { createI18nContext } from '@sheet-i18n/react';
|
|
1019
1071
|
|
|
1020
1072
|
export const { IntlProvider, useTranslation } = createI18nContext(i18nStore);
|
|
1021
1073
|
|
|
@@ -1176,16 +1228,16 @@ The configuration of export command is based on **`sheet.config.ts`** on your ro
|
|
|
1176
1228
|
---
|
|
1177
1229
|
|
|
1178
1230
|
<details open>
|
|
1179
|
-
<summary><strong>🌍 Server Export Function - sheet-i18n/importer</strong></summary>
|
|
1231
|
+
<summary><strong>🌍 Server Export Function - @sheet-i18n/importer</strong></summary>
|
|
1180
1232
|
|
|
1181
|
-
###
|
|
1233
|
+
### `@sheet-i18n/importer`
|
|
1182
1234
|
|
|
1183
1235
|
[](https://npmjs.com/package/@sheet-i18n/importer)
|
|
1184
1236
|
|
|
1185
1237
|
The **server-side importer** subpackage allows you to interact with Google Sheets and export translations directly into your project. This is primarily used in server-side environments, such as Next.js API routes or other backend frameworks, where you want to fetch and store translations from a Google Spreadsheet to be served to clients or used within your server application.
|
|
1186
1238
|
|
|
1187
1239
|
```jsx
|
|
1188
|
-
import { googleSheetImporter } from 'sheet-i18n/importer';
|
|
1240
|
+
import { googleSheetImporter } from '@sheet-i18n/importer';
|
|
1189
1241
|
|
|
1190
1242
|
const importer = await googleSheetImporter({
|
|
1191
1243
|
credentials: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '@sheet-i18n/importer';
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
var src_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(src_exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheet-i18n",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "1.10.
|
|
3
|
+
"description": "Core i18n toolchain for sheet-i18n: configuration types and server-side importer for Google Sheets workflows.",
|
|
4
|
+
"version": "1.10.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/chltjdrhd777/sheet-i18n"
|
|
@@ -17,16 +17,6 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"import": "./dist/index.mjs",
|
|
19
19
|
"require": "./dist/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./importer": {
|
|
22
|
-
"require": "./dist/importer/index.js",
|
|
23
|
-
"import": "./dist/importer/index.mjs",
|
|
24
|
-
"types": "./dist/importer/index.d.ts"
|
|
25
|
-
},
|
|
26
|
-
"./react": {
|
|
27
|
-
"require": "./dist/react/index.js",
|
|
28
|
-
"import": "./dist/react/index.mjs",
|
|
29
|
-
"types": "./dist/react/index.d.ts"
|
|
30
20
|
}
|
|
31
21
|
},
|
|
32
22
|
"keywords": [
|
|
@@ -49,11 +39,7 @@
|
|
|
49
39
|
},
|
|
50
40
|
"license": "ISC",
|
|
51
41
|
"homepage": "https://github.com/chltjdrhd777/sheet-i18n",
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@sheet-i18n/react": "1.6.1",
|
|
54
|
-
"@sheet-i18n/importer": "1.9.6",
|
|
55
|
-
"@sheet-i18n/typescript": "0.3.0"
|
|
56
|
-
},
|
|
42
|
+
"dependencies": {},
|
|
57
43
|
"devDependencies": {
|
|
58
44
|
"tsup": "^6.0.0",
|
|
59
45
|
"typescript": "^5.0.0",
|
package/dist/importer/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@sheet-i18n/importer';
|
package/dist/importer/index.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/importer/index.ts
|
|
18
|
-
var importer_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(importer_exports);
|
|
20
|
-
__reExport(importer_exports, require("@sheet-i18n/importer"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("@sheet-i18n/importer")
|
|
24
|
-
});
|
package/dist/importer/index.mjs
DELETED
package/dist/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@sheet-i18n/react';
|
package/dist/react/index.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/react/index.ts
|
|
18
|
-
var react_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(react_exports);
|
|
20
|
-
__reExport(react_exports, require("@sheet-i18n/react"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("@sheet-i18n/react")
|
|
24
|
-
});
|
package/dist/react/index.mjs
DELETED