sheet-i18n 0.1.8 → 0.1.9
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/.turbo/turbo-build.log +13 -9
- package/dist/chunk-7AQPNLGW.mjs +7 -0
- package/dist/exporter/index.d.ts +23 -0
- package/dist/exporter/index.js +24 -0
- package/dist/exporter/index.mjs +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +12 -2
- package/dist/index.mjs +6 -2
- package/package.json +6 -6
- package/src/exporter/index.ts +1 -0
- package/src/index.ts +1 -1
- package/.turbo/turbo-changelog.log +0 -12
- package/.turbo/turbo-publish$colon$pnpm.log +0 -38
- package/README.md +0 -187
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> sheet-i18n@0.1.
|
|
3
|
+
> sheet-i18n@0.1.9 build /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts, src/exporter/index.ts
|
|
7
7
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
8
|
[34mCLI[39m tsup v6.7.0
|
|
9
|
-
[34mCLI[39m Using tsup config: /Users/
|
|
9
|
+
[34mCLI[39m Using tsup config: /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n/tsup.config.ts
|
|
10
10
|
[34mCLI[39m Target: node14
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[34mESM[39m Build start
|
|
14
|
-
[32mCJS[39m [1mdist/index.js
|
|
15
|
-
[32mCJS[39m
|
|
16
|
-
[
|
|
17
|
-
[32mESM[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.28 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/exporter/index.js [22m[32m1.10 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 10ms
|
|
17
|
+
[32mESM[39m [1mdist/chunk-7AQPNLGW.mjs [22m[32m122.00 B[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m102.00 B[39m
|
|
19
|
+
[32mESM[39m [1mdist/exporter/index.mjs [22m[32m32.00 B[39m
|
|
20
|
+
[32mESM[39m ⚡️ Build success in 11ms
|
|
18
21
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
22
|
+
[32mDTS[39m ⚡️ Build success in 543ms
|
|
23
|
+
[32mDTS[39m [1mdist/exporter/index.d.ts [22m[32m592.00 B[39m
|
|
24
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m84.00 B[39m
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as exporter from '@sheet-i18n/exporter';
|
|
2
|
+
export * from '@sheet-i18n/exporter';
|
|
3
|
+
|
|
4
|
+
function _mergeNamespaces(n, m) {
|
|
5
|
+
m.forEach(function (e) {
|
|
6
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
7
|
+
if (k !== 'default' && !(k in n)) {
|
|
8
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return e[k]; }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return Object.freeze(n);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var index = /*#__PURE__*/_mergeNamespaces({
|
|
20
|
+
__proto__: null
|
|
21
|
+
}, [exporter]);
|
|
22
|
+
|
|
23
|
+
export { index as i };
|
|
@@ -0,0 +1,24 @@
|
|
|
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/exporter/index.ts
|
|
18
|
+
var exporter_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(exporter_exports);
|
|
20
|
+
__reExport(exporter_exports, require("@sheet-i18n/exporter"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@sheet-i18n/exporter")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-7AQPNLGW.mjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { i as exporter } from './exporter/index.js';
|
|
2
|
+
import '@sheet-i18n/exporter';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -16,9 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
20
|
|
|
17
21
|
// src/index.ts
|
|
18
22
|
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
exporter: () => exporter_exports
|
|
25
|
+
});
|
|
19
26
|
module.exports = __toCommonJS(src_exports);
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
// src/exporter/index.ts
|
|
29
|
+
var exporter_exports = {};
|
|
30
|
+
__reExport(exporter_exports, require("@sheet-i18n/exporter"));
|
|
21
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
32
|
0 && (module.exports = {
|
|
23
|
-
|
|
33
|
+
exporter
|
|
24
34
|
});
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheet-i18n",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"main": "
|
|
5
|
-
"module": "
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsup",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"publish:npm": "npm publish"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
|
-
"
|
|
15
|
-
"require": "./dist/index.js",
|
|
16
|
-
"import": "./dist/index.mjs"
|
|
14
|
+
"/exporter": {
|
|
15
|
+
"require": "./dist/exporter/index.js",
|
|
16
|
+
"import": "./dist/exporter/index.mjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@sheet-i18n/exporter';
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * as exporter from './exporter';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> sheet-i18n@0.1.4 changelog /Users/choeucheol/Documents/dev/project/sheet-i18n/packages/sheet-i18n
|
|
4
|
-
> standard-version
|
|
5
|
-
|
|
6
|
-
[32m✔[39m bumping version in package.json from [1m0.1.4[22m to [1m0.1.5[22m
|
|
7
|
-
[32m✔[39m outputting changes to [1mCHANGELOG.md[22m
|
|
8
|
-
[32m✔[39m committing [1mpackage.json[22m and [1mCHANGELOG.md[22m
|
|
9
|
-
[33m→ No staged files match any configured task.[39m
|
|
10
|
-
[33m[39m
|
|
11
|
-
[32m✔[39m tagging release [1mv[22m[1m0.1.5[22m
|
|
12
|
-
[34mℹ[39m Run `[1mgit push --follow-tags origin feature && npm publish[22m` to publish
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> sheet-i18n@0.1.5 publish:pnpm /Users/choeucheol/Documents/dev/project/sheet-i18n/packages/sheet-i18n
|
|
4
|
-
> pnpm publish --access public
|
|
5
|
-
|
|
6
|
-
[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m
|
|
7
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 📦 sheet-i18n@0.1.5
|
|
8
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m [0m[35m=== Tarball Contents ===[0m
|
|
9
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 1.1kB .turbo/turbo-build.log
|
|
10
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 566B .turbo/turbo-changelog.log
|
|
11
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 3.0kB .turbo/turbo-publish$colon$npm.log
|
|
12
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 0B .turbo/turbo-publish$colon$pnpm.log
|
|
13
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 1.4kB CHANGELOG.md
|
|
14
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 6.9kB README.md
|
|
15
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 122B dist/chunk-7AQPNLGW.mjs
|
|
16
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 592B dist/exporter/index.d.ts
|
|
17
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 1.1kB dist/exporter/index.js
|
|
18
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 32B dist/exporter/index.mjs
|
|
19
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 84B dist/index.d.ts
|
|
20
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 1.3kB dist/index.js
|
|
21
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 102B dist/index.mjs
|
|
22
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 883B package.json
|
|
23
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 38B src/exporter/index.ts
|
|
24
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 40B src/index.ts
|
|
25
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 196B tsconfig.json
|
|
26
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m 196B tsup.config.ts
|
|
27
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m [0m[35m=== Tarball Details ===[0m
|
|
28
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m name: sheet-i18n
|
|
29
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m version: 0.1.5
|
|
30
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m filename: sheet-i18n-0.1.5.tgz
|
|
31
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m package size: 5.9 kB
|
|
32
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m unpacked size: 17.7 kB
|
|
33
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m shasum: cbc510eba59abef5d55d51d61a23093a1a6cd1dd
|
|
34
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m integrity: sha512-rqJwB/B8oTzXf[...]jdKg4YdN6DnGw==
|
|
35
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m total files: 18
|
|
36
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m
|
|
37
|
-
[0m[37;40mnpm[0m [0m[36;40mnotice[0m[35m[0m Publishing to https://registry.npmjs.org/ with tag latest and public access
|
|
38
|
-
[0m+ sheet-i18n@0.1.5
|
package/README.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# sheet-i18n
|
|
2
|
-
|
|
3
|
-
**An all-in-one package for sheet-based translations.**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/sheet-i18n)
|
|
6
|
-
<a href="https://sheet-i18n.vercel.app/en" target="_blank">
|
|
7
|
-
|
|
8
|
-
<!-- <img height="20px" src="https://img.shields.io/badge/📚-%20Docs-%23000000"/> -->
|
|
9
|
-
</a>
|
|
10
|
-
|
|
11
|
-
## Installation 🛠️
|
|
12
|
-
|
|
13
|
-
You can install **sheet-i18n** via npm:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install sheet-i18n
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage 🚀
|
|
20
|
-
|
|
21
|
-
### 📑 Main Package - `sheet-i18n`
|
|
22
|
-
|
|
23
|
-
This is the core package for sheet-based translations. You can use it to work with Google Sheets and export translations.
|
|
24
|
-
|
|
25
|
-
<details open>
|
|
26
|
-
<summary>📄 Server export function - `sheet-i18n/exporter`</summary>
|
|
27
|
-
|
|
28
|
-
#### `sheet-i18n/exporter`
|
|
29
|
-
|
|
30
|
-
The **server-side exporter** 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.
|
|
31
|
-
|
|
32
|
-
```jsx
|
|
33
|
-
import { googleSheetExporter } from 'sheet-i18n/exporter';
|
|
34
|
-
|
|
35
|
-
const exporter = await googleSheetExporter({
|
|
36
|
-
credentials: {
|
|
37
|
-
sheetId: 'your-google-sheet-id',
|
|
38
|
-
clientEmail: 'your-client-email',
|
|
39
|
-
privateKey: 'your-private-key',
|
|
40
|
-
},
|
|
41
|
-
defaultLocale: 'default-language',
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
await exporter.exportTranslations();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Configuration ⚙️
|
|
48
|
-
|
|
49
|
-
The configuration object required for using the exporter is as follows:
|
|
50
|
-
|
|
51
|
-
#### Required 📝
|
|
52
|
-
|
|
53
|
-
- **`credentials`**: Google Sheets API credentials:
|
|
54
|
-
- `sheetId`: The ID of your Google Spreadsheet (extracted from the URL).
|
|
55
|
-
- `clientEmail`: The email of the Google Sheets API client.
|
|
56
|
-
- `privateKey`: The private key associated with the client.
|
|
57
|
-
- **`defaultLocale`**: The default locale/language specified in your Google Sheet header.
|
|
58
|
-
|
|
59
|
-
#### Optional 🔧
|
|
60
|
-
|
|
61
|
-
- **`headerStartRowNumber`**: Specifies the row number where the headers begin (if not at the top).
|
|
62
|
-
- **`ignoredSheets`**: A list of sheets to exclude by title. By default, sheets without the `defaultLocale` in headers will be ignored.
|
|
63
|
-
- **`exportPath`**: Path to save exported translations. 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 `exportTranslations` method.
|
|
64
|
-
|
|
65
|
-
### Exporter Methods 🛠️
|
|
66
|
-
|
|
67
|
-
#### `getTranslations` 📝
|
|
68
|
-
|
|
69
|
-
- **Description**: This function retrieves the translation data, which is structured by locale keys (such as "ko", "en", etc.). It collects all translations from the specified sheet, replaces any placeholders, and prepares them to be sent to the client in the response body. Each key corresponds to a language, and the value for each key is an object containing the translated text for that locale.
|
|
70
|
-
|
|
71
|
-
- **Type**: Function
|
|
72
|
-
- **Parameters**: None
|
|
73
|
-
- **Returns**: An object where each key is a locale (e.g., "ko", "en"), and the value is the respective translation data for that locale.
|
|
74
|
-
|
|
75
|
-
#### Example:
|
|
76
|
-
|
|
77
|
-
If the headers in your Google Sheets are `["ko", "en", ...]`, the result returned by `getTranslations` will look like this:
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
{
|
|
81
|
-
"ko": {
|
|
82
|
-
"greeting": "안녕하세요",
|
|
83
|
-
"farewell": "안녕히 가세요"
|
|
84
|
-
},
|
|
85
|
-
"en": {
|
|
86
|
-
"greeting": "Hello",
|
|
87
|
-
"farewell": "Goodbye"
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
...
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
In this example:
|
|
95
|
-
|
|
96
|
-
- `"ko"` contains the translations for Korean.
|
|
97
|
-
- `"en"` contains the translations for English.
|
|
98
|
-
Each locale’s object contains key-value pairs for individual translations.
|
|
99
|
-
|
|
100
|
-
#### `exportTranslations` 📤
|
|
101
|
-
|
|
102
|
-
- **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.
|
|
103
|
-
|
|
104
|
-
- **Type**: Function
|
|
105
|
-
- **Parameters**: None
|
|
106
|
-
- **Returns**: `void`
|
|
107
|
-
|
|
108
|
-
#### Example:
|
|
109
|
-
|
|
110
|
-
If you call the `exportTranslations` function, it will update or create JSON files in your project for each locale. The result could look like this:
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
// ko.json
|
|
114
|
-
{
|
|
115
|
-
"greeting": "안녕하세요",
|
|
116
|
-
"farewell": "안녕히 가세요"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// en.json
|
|
120
|
-
{
|
|
121
|
-
"greeting": "Hello",
|
|
122
|
-
"farewell": "Goodbye"
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### API Documentation 📚
|
|
127
|
-
|
|
128
|
-
You can refer to the Google Sheets API for integration details and configuration. The following link provides extensive documentation on how to interact with Google Sheets API for accessing your spreadsheet data:
|
|
129
|
-
|
|
130
|
-
[Google Sheets API Documentation](https://developers.google.com/sheets/api)
|
|
131
|
-
|
|
132
|
-
### Exporting Data Format 🗂️
|
|
133
|
-
|
|
134
|
-
The exported translations will be saved in a format that is easy to use for localization purposes. Each translation is stored in its respective locale folder, with a structured format.
|
|
135
|
-
|
|
136
|
-
</details>
|
|
137
|
-
|
|
138
|
-
<!--
|
|
139
|
-
<details>
|
|
140
|
-
<summary>⚛️ React Component - `sheet-i18n/react`</summary>
|
|
141
|
-
|
|
142
|
-
#### `sheet-i18n/react`
|
|
143
|
-
|
|
144
|
-
The **React component** subpackage allows you to use translations within your React application. This is ideal for rendering dynamic translations on the frontend, where you may need to load and display translations from a Google Spreadsheet based on the current locale selected by the user.
|
|
145
|
-
|
|
146
|
-
```jsx
|
|
147
|
-
import { useState, useEffect } from 'react';
|
|
148
|
-
import { googleSheetExporter } from 'sheet-i18n/react';
|
|
149
|
-
|
|
150
|
-
const TranslationProvider = ({ children }) => {
|
|
151
|
-
const [translations, setTranslations] = useState({});
|
|
152
|
-
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
const fetchTranslations = async () => {
|
|
155
|
-
const exporter = await googleSheetExporter({
|
|
156
|
-
credentials: {
|
|
157
|
-
sheetId: 'your-google-sheet-id',
|
|
158
|
-
clientEmail: 'your-client-email',
|
|
159
|
-
privateKey: 'your-private-key',
|
|
160
|
-
},
|
|
161
|
-
defaultLocale: 'en',
|
|
162
|
-
});
|
|
163
|
-
const data = await exporter.getTranslations();
|
|
164
|
-
setTranslations(data);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
fetchTranslations();
|
|
168
|
-
}, []);
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<TranslationContext.Provider value={translations}>
|
|
172
|
-
{children}
|
|
173
|
-
</TranslationContext.Provider>
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
This is useful for applications where translations need to be loaded and displayed dynamically from a backend (e.g., Google Sheets). You can use this provider to wrap your app and pass translations to components.
|
|
179
|
-
|
|
180
|
-
</details>
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## Additional Notes 📌
|
|
185
|
-
|
|
186
|
-
- **Locales**: Ensure that the first row in your Google Sheet contains the locale headers (e.g., `["ko", "en", "fr"]`).
|
|
187
|
-
- **Placeholders**: Any placeholders within the translation strings will be replaced during the export process. -->
|