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.
@@ -1,20 +1,24 @@
1
1
 
2
2
  
3
- > sheet-i18n@0.1.8 build /Users/choeucheol/Documents/dev/project/sheet-i18n/packages/sheet-i18n
3
+ > sheet-i18n@0.1.9 build /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
4
4
  > tsup
5
5
 
6
- CLI Building entry: src/index.ts
6
+ CLI Building entry: src/index.ts, src/exporter/index.ts
7
7
  CLI Using tsconfig: tsconfig.json
8
8
  CLI tsup v6.7.0
9
- CLI Using tsup config: /Users/choeucheol/Documents/dev/project/sheet-i18n/packages/sheet-i18n/tsup.config.ts
9
+ CLI Using tsup config: /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n/tsup.config.ts
10
10
  CLI Target: node14
11
11
  CLI Cleaning output folder
12
12
  CJS Build start
13
13
  ESM Build start
14
- CJS dist/index.js 1.08 KB
15
- CJS ⚡️ Build success in 7ms
16
- ESM dist/index.mjs 54.00 B
17
- ESM ⚡️ Build success in 7ms
14
+ CJS dist/index.js 1.28 KB
15
+ CJS dist/exporter/index.js 1.10 KB
16
+ CJS ⚡️ Build success in 10ms
17
+ ESM dist/chunk-7AQPNLGW.mjs 122.00 B
18
+ ESM dist/index.mjs 102.00 B
19
+ ESM dist/exporter/index.mjs 32.00 B
20
+ ESM ⚡️ Build success in 11ms
18
21
  DTS Build start
19
- DTS ⚡️ Build success in 316ms
20
- DTS dist/index.d.ts 38.00 B
22
+ DTS ⚡️ Build success in 543ms
23
+ DTS dist/exporter/index.d.ts 592.00 B
24
+ DTS dist/index.d.ts 84.00 B
@@ -0,0 +1,7 @@
1
+ // src/exporter/index.ts
2
+ var exporter_exports = {};
3
+ export * from "@sheet-i18n/exporter";
4
+
5
+ export {
6
+ exporter_exports
7
+ };
@@ -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 * from '@sheet-i18n/exporter';
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
- __reExport(src_exports, require("@sheet-i18n/exporter"), module.exports);
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
- ...require("@sheet-i18n/exporter")
33
+ exporter
24
34
  });
package/dist/index.mjs CHANGED
@@ -1,2 +1,6 @@
1
- // src/index.ts
2
- export * from "@sheet-i18n/exporter";
1
+ import {
2
+ exporter_exports
3
+ } from "./chunk-7AQPNLGW.mjs";
4
+ export {
5
+ exporter_exports as exporter
6
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "sheet-i18n",
3
- "version": "0.1.8",
4
- "main": "./dist/index.js",
5
- "module": "./dist/index.mjs",
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 '@sheet-i18n/exporter';
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
- ✔ bumping version in package.json from 0.1.4 to 0.1.5
7
- ✔ outputting changes to CHANGELOG.md
8
- ✔ committing package.json and CHANGELOG.md
9
- → No staged files match any configured task.
10
- 
11
- ✔ tagging release v0.1.5
12
- ℹ Run `git push --follow-tags origin feature && npm publish` 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
- npm notice
7
- npm notice 📦 sheet-i18n@0.1.5
8
- npm notice === Tarball Contents ===
9
- npm notice 1.1kB .turbo/turbo-build.log
10
- npm notice 566B .turbo/turbo-changelog.log
11
- npm notice 3.0kB .turbo/turbo-publish$colon$npm.log
12
- npm notice 0B .turbo/turbo-publish$colon$pnpm.log
13
- npm notice 1.4kB CHANGELOG.md
14
- npm notice 6.9kB README.md
15
- npm notice 122B dist/chunk-7AQPNLGW.mjs
16
- npm notice 592B dist/exporter/index.d.ts
17
- npm notice 1.1kB dist/exporter/index.js
18
- npm notice 32B dist/exporter/index.mjs
19
- npm notice 84B dist/index.d.ts
20
- npm notice 1.3kB dist/index.js
21
- npm notice 102B dist/index.mjs
22
- npm notice 883B package.json
23
- npm notice 38B src/exporter/index.ts
24
- npm notice 40B src/index.ts
25
- npm notice 196B tsconfig.json
26
- npm notice 196B tsup.config.ts
27
- npm notice === Tarball Details ===
28
- npm notice name: sheet-i18n
29
- npm notice version: 0.1.5
30
- npm notice filename: sheet-i18n-0.1.5.tgz
31
- npm notice package size: 5.9 kB
32
- npm notice unpacked size: 17.7 kB
33
- npm notice shasum: cbc510eba59abef5d55d51d61a23093a1a6cd1dd
34
- npm notice integrity: sha512-rqJwB/B8oTzXf[...]jdKg4YdN6DnGw==
35
- npm notice total files: 18
36
- npm notice
37
- npm notice Publishing to https://registry.npmjs.org/ with tag latest and public access
38
- + 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
- [![npm](https://img.shields.io/npm/v/sheet-i18n)](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. -->