sheet-i18n 1.3.18 β 1.3.20-canary.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.
package/README.md
CHANGED
|
@@ -26,23 +26,23 @@ It serves as a bridge between your translation data and your application, offeri
|
|
|
26
26
|
|
|
27
27
|
The `sheet-i18n` ecosystem is divided into three main packages:
|
|
28
28
|
|
|
29
|
-
- `sheet-i18n/
|
|
29
|
+
- `sheet-i18n/importer`
|
|
30
30
|
- `sheet-i18n/react`
|
|
31
31
|
- `@sheet-i18n/cli`
|
|
32
32
|
|
|
33
33
|
<br/>
|
|
34
34
|
|
|
35
|
-
<details>
|
|
36
|
-
<summary>π Server Export Function - sheet-i18n/
|
|
35
|
+
<details open>
|
|
36
|
+
<summary>π Server Export Function - sheet-i18n/importer</summary>
|
|
37
37
|
|
|
38
|
-
#### `sheet-i18n/
|
|
38
|
+
#### `sheet-i18n/importer`
|
|
39
39
|
|
|
40
|
-
The **server-side
|
|
40
|
+
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.
|
|
41
41
|
|
|
42
42
|
```jsx
|
|
43
|
-
import {
|
|
43
|
+
import { googleSheetImporter } from 'sheet-i18n/importer';
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const importer = await googleSheetImporter({
|
|
46
46
|
credentials: {
|
|
47
47
|
sheetId: 'your-google-sheet-id',
|
|
48
48
|
clientEmail: 'your-client-email',
|
|
@@ -51,12 +51,12 @@ const exporter = await googleSheetExporter({
|
|
|
51
51
|
defaultLocale: 'default-language-in-sheet-header',
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
await
|
|
54
|
+
await importer.importTranslations();
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### Configuration βοΈ
|
|
58
58
|
|
|
59
|
-
The configuration object required for using the
|
|
59
|
+
The configuration object required for using the importer is as follows:
|
|
60
60
|
|
|
61
61
|
#### Required π
|
|
62
62
|
|
|
@@ -70,9 +70,9 @@ The configuration object required for using the exporter is as follows:
|
|
|
70
70
|
|
|
71
71
|
- **`headerStartRowNumber`**: Specifies the row number where the headers begin (if not at the top).
|
|
72
72
|
- **`ignoredSheets`**: A list of sheets to exclude by title. By default, sheets without the `defaultLocale` in headers will be ignored.
|
|
73
|
-
- **`
|
|
73
|
+
- **`importPath`**: Path to save exported translations from your sheet. This is the location where the exported translations will be saved. By default, it will use the current working directory (cwd). This option is only used when calling the `importTranslations` method.
|
|
74
74
|
|
|
75
|
-
###
|
|
75
|
+
### Importer Methods π οΈ
|
|
76
76
|
|
|
77
77
|
#### `getTranslations` π
|
|
78
78
|
|
|
@@ -107,7 +107,7 @@ In this example:
|
|
|
107
107
|
- `"en"` contains the translations for English.
|
|
108
108
|
Each localeβs object contains key-value pairs for individual translations.
|
|
109
109
|
|
|
110
|
-
#### `
|
|
110
|
+
#### `importTranslations` π€
|
|
111
111
|
|
|
112
112
|
- **Description**: This asynchronous function is used in a Node.js environment to export translations directly into your project. It is especially useful if your project includes server-side APIs (like Next.js API routes) and you need to update the locale JSON data in your project. It can be invoked to update or create the locale files within your project, ensuring that the translation data is synced with the local environment.
|
|
113
113
|
|
|
@@ -117,7 +117,7 @@ In this example:
|
|
|
117
117
|
|
|
118
118
|
#### Example:
|
|
119
119
|
|
|
120
|
-
If you call the `
|
|
120
|
+
If you call the `importTranslations` function, it will update or create JSON files in your project for each locale. The result could look like this:
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
123
|
// ko.json
|
|
@@ -740,7 +740,7 @@ Example `sheet.config.json`:
|
|
|
740
740
|
"defaultLocale": "en",
|
|
741
741
|
"supportedLocales": ["en", "fr", "es"],
|
|
742
742
|
"ignoredSheets": ["BASE"],
|
|
743
|
-
"
|
|
743
|
+
"importPath": "./src/locales"
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
```
|
|
@@ -759,7 +759,7 @@ Example `sheet.config.json`:
|
|
|
759
759
|
- **`supportedLocales(required)`**: List of locales supported in your sheet (default: [defaultLocale]).
|
|
760
760
|
- **headerStartRowNumber** (optional): Row number where headers start (default: 1).
|
|
761
761
|
- **ignoredSheets** (optional): Titles of sheets to exclude from the translation process.
|
|
762
|
-
- **
|
|
762
|
+
- **importPath** (optional): Directory path to save exported translations based on the current working directory (default: `.`).
|
|
763
763
|
|
|
764
764
|
## Commands
|
|
765
765
|
|
|
@@ -834,7 +834,7 @@ Registers translation data to Google Sheets.
|
|
|
834
834
|
|
|
835
835
|
2. It updates rows and adds "translation" entries using the `GOOGLETRANSLATE` function supported by Google Spreadsheets for automated translations.
|
|
836
836
|
|
|
837
|
-
3. After registering, it asks whether you want to update the locale JSON data locally. It then exports the JSON data to the `
|
|
837
|
+
3. After registering, it asks whether you want to update the locale JSON data locally. It then exports the JSON data to the `importPath` specified in `sheet.config.json` (default is the current working directory).
|
|
838
838
|
|
|
839
839
|
#### Options:
|
|
840
840
|
|
|
@@ -896,7 +896,7 @@ The configuration of export command is based on **`sheet.config.json`** on your
|
|
|
896
896
|
},
|
|
897
897
|
"defaultLocale": "The base language of your application in sheet header",
|
|
898
898
|
"ignoredSheets": ["BASE"],
|
|
899
|
-
"
|
|
899
|
+
"importPath": "The path of export directory of translation data. (default: current working directory)"
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@sheet-i18n/importer';
|
|
@@ -14,11 +14,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
|
|
17
|
-
// src/
|
|
18
|
-
var
|
|
19
|
-
module.exports = __toCommonJS(
|
|
20
|
-
__reExport(
|
|
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
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
22
|
0 && (module.exports = {
|
|
23
|
-
...require("@sheet-i18n/
|
|
23
|
+
...require("@sheet-i18n/importer")
|
|
24
24
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@sheet-i18n/react';
|
|
2
|
-
import '@sheet-i18n/
|
|
2
|
+
import '@sheet-i18n/importer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheet-i18n",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20-canary.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/chltjdrhd777/sheet-i18n"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"dist/**/*"
|
|
13
13
|
],
|
|
14
14
|
"exports": {
|
|
15
|
-
"./
|
|
16
|
-
"require": "./dist/
|
|
17
|
-
"import": "./dist/
|
|
18
|
-
"types": "./dist/
|
|
15
|
+
"./importer": {
|
|
16
|
+
"require": "./dist/importer/index.js",
|
|
17
|
+
"import": "./dist/importer/index.mjs",
|
|
18
|
+
"types": "./dist/importer/index.d.ts"
|
|
19
19
|
},
|
|
20
20
|
"./react": {
|
|
21
21
|
"require": "./dist/react/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
},
|
|
37
37
|
"license": "ISC",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@sheet-i18n/
|
|
40
|
-
"@sheet-i18n/
|
|
39
|
+
"@sheet-i18n/importer": "1.3.13-canary.0",
|
|
40
|
+
"@sheet-i18n/react": "1.0.14-canary.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"tsup": "^6.0.0",
|
|
44
44
|
"typescript": "^5.0.0",
|
|
45
|
-
"@sheet-i18n/typescript-config": "1.3.
|
|
45
|
+
"@sheet-i18n/typescript-config": "1.3.11-canary.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup",
|
package/dist/exporter/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@sheet-i18n/exporter';
|
package/dist/exporter/index.mjs
DELETED