sheet-i18n 0.1.9 → 0.1.11

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,6 +1,6 @@
1
1
 
2
2
  
3
- > sheet-i18n@0.1.9 build /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
3
+ > sheet-i18n@0.1.10 build /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts, src/exporter/index.ts
@@ -11,14 +11,14 @@
11
11
  CLI Cleaning output folder
12
12
  CJS Build start
13
13
  ESM Build start
14
- CJS dist/index.js 1.28 KB
15
- CJS dist/exporter/index.js 1.10 KB
16
- CJS ⚡️ Build success in 10ms
17
14
  ESM dist/chunk-7AQPNLGW.mjs 122.00 B
18
15
  ESM dist/index.mjs 102.00 B
19
16
  ESM dist/exporter/index.mjs 32.00 B
20
17
  ESM ⚡️ Build success in 11ms
18
+ CJS dist/exporter/index.js 1.10 KB
19
+ CJS dist/index.js 1.28 KB
20
+ CJS ⚡️ Build success in 11ms
21
21
  DTS Build start
22
- DTS ⚡️ Build success in 543ms
22
+ DTS ⚡️ Build success in 471ms
23
23
  DTS dist/exporter/index.d.ts 592.00 B
24
24
  DTS dist/index.d.ts 84.00 B
@@ -0,0 +1,12 @@
1
+
2
+ 
3
+ > sheet-i18n@0.1.9 changelog /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
4
+ > standard-version
5
+
6
+ ✔ bumping version in package.json from 0.1.9 to 0.1.10
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.10
12
+ ℹ Run `git push --follow-tags origin feature && npm publish` to publish
@@ -0,0 +1,38 @@
1
+
2
+ 
3
+ > sheet-i18n@0.1.10 publish:npm /Users/devanderson/Documents/dev/project/sheet-i18n/packages/sheet-i18n
4
+ > npm publish
5
+
6
+ ⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋npm notice
7
+ ⠋npm notice 📦 sheet-i18n@0.1.10
8
+ ⠋npm notice Tarball Contents
9
+ ⠋npm notice 1.1kB .turbo/turbo-build.log
10
+ npm notice 569B .turbo/turbo-changelog.log
11
+ npm notice 0B .turbo/turbo-publish$colon$npm.log
12
+ npm notice 4.3kB CHANGELOG.md
13
+ npm notice 6.8kB README.md
14
+ npm notice 122B dist/chunk-7AQPNLGW.mjs
15
+ npm notice 592B dist/exporter/index.d.ts
16
+ npm notice 1.1kB dist/exporter/index.js
17
+ npm notice 32B dist/exporter/index.mjs
18
+ npm notice 84B dist/index.d.ts
19
+ npm notice 1.3kB dist/index.js
20
+ npm notice 102B dist/index.mjs
21
+ npm notice 845B package.json
22
+ npm notice 38B src/exporter/index.ts
23
+ npm notice 40B src/index.ts
24
+ npm notice 196B tsconfig.json
25
+ npm notice 196B tsup.config.ts
26
+ ⠋npm notice Tarball Details
27
+ ⠋npm notice name: sheet-i18n
28
+ ⠋npm notice version: 0.1.10
29
+ ⠋npm notice filename: sheet-i18n-0.1.10.tgz
30
+ ⠋npm notice package size: 6.7 kB
31
+ ⠋npm notice unpacked size: 17.4 kB
32
+ ⠋npm notice shasum: 15000bc70579e0bd773ca4529ce9b953a5723989
33
+ ⠋npm notice integrity: sha512-I0fEIr19Menfx[...]6GyTQ//r1S8+g==
34
+ ⠋npm notice total files: 17
35
+ ⠋npm notice
36
+ ⠋npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access
37
+ ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋+ sheet-i18n@0.1.10
38
+ ⠋
package/CHANGELOG.md CHANGED
@@ -1,10 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - changeset applying test for versioning and publishing
8
+
3
9
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
10
 
5
- ### [0.1.1](https://github.com/chltjdrhd777/sheet-i18n/compare/v0.1.2...v0.1.1) (2024-12-23)
11
+ ### 0.1.10 (2024-12-23)
12
+
13
+ ### Features
14
+
15
+ - add changelog script to track changes ([9a07986](https://github.com/chltjdrhd777/sheet-i18n/commit/9a07986b0da9a3ffaa702888284df5059c64f776))
16
+ - add husky ([a55a51c](https://github.com/chltjdrhd777/sheet-i18n/commit/a55a51c7e1d279002dddcaf2b4e957d6180a83d5))
17
+ - add ignore sheet by title params ([82fc9ed](https://github.com/chltjdrhd777/sheet-i18n/commit/82fc9edf52f201b74cc22c7a129d8d9fb5880dc8))
18
+ - add lint-staged pre commit script ([53d3e0c](https://github.com/chltjdrhd777/sheet-i18n/commit/53d3e0c6aced647e3b47063cd23bf134345e73a5))
19
+ - add vitest setting ([62e6562](https://github.com/chltjdrhd777/sheet-i18n/commit/62e65629c68b92766f4509039405330508ba1d93))
20
+ - apply husky commit lint ([6ae99da](https://github.com/chltjdrhd777/sheet-i18n/commit/6ae99da9c448d23916ba97a6ae7d89546464dd75))
21
+ - create exportSheet method for creating translation json data ([732786e](https://github.com/chltjdrhd777/sheet-i18n/commit/732786e5dd32d4a0d3ac28607fe92117720160e6))
22
+ - create getTranslationData method to get translation data ([37faff0](https://github.com/chltjdrhd777/sheet-i18n/commit/37faff07f60af4369604ef36ed9ae5a06225a1d7))
23
+ - create translation json data method ([d30774f](https://github.com/chltjdrhd777/sheet-i18n/commit/d30774fe86a5486008530f3c1bb80edcf58c9d0f))
24
+ - create WorkSheetManager class ([522a65f](https://github.com/chltjdrhd777/sheet-i18n/commit/522a65f9f587c2fbbb5678dcac222fcc87beb1cc))
25
+ - **create-turbo:** apply official-starter transform ([acfb9e3](https://github.com/chltjdrhd777/sheet-i18n/commit/acfb9e31fe9cc659700c6050d26f78a0065164f7))
26
+ - **create-turbo:** apply pnpm-eslint transform ([9e76869](https://github.com/chltjdrhd777/sheet-i18n/commit/9e76869210372a92e1da13350f6bef42fbbba96b))
27
+ - **create-turbo:** create basic ([1a5e142](https://github.com/chltjdrhd777/sheet-i18n/commit/1a5e1421e90b02efd1d8f5ff72bf83a9e2f4db78))
28
+ - **create-turbo:** install dependencies ([ff1aeea](https://github.com/chltjdrhd777/sheet-i18n/commit/ff1aeeabbe3d5b704a170fb4974168d4ac9c334c))
29
+ - init turbo-repo based repo ([2019285](https://github.com/chltjdrhd777/sheet-i18n/commit/20192855844fe8fb2b31ad00fdd6ab7714dd082a))
30
+ - make sheet exporter base ([9fc56ba](https://github.com/chltjdrhd777/sheet-i18n/commit/9fc56ba8e24ce021dbc3f65c051549948f961608))
31
+ - prepare publish all packages ([036eba2](https://github.com/chltjdrhd777/sheet-i18n/commit/036eba202cb23f928a91122f28623b70853e62dd))
32
+ - prettier, plop file 적용 ([806fa60](https://github.com/chltjdrhd777/sheet-i18n/commit/806fa607754fb41a01a15303dee693087f6f0966))
33
+
34
+ ### Bug Fixes
6
35
 
36
+ - add format flag on dev mode ([2abff0a](https://github.com/chltjdrhd777/sheet-i18n/commit/2abff0a580865361019dce3bb103e5aed01cf6e0))
37
+ - change vscode eslint setting to format ([2c7513d](https://github.com/chltjdrhd777/sheet-i18n/commit/2c7513d6c37f57e9cf90fd5868ab40d61cda8366))
38
+ - eslint global config migration ([2573251](https://github.com/chltjdrhd777/sheet-i18n/commit/25732516e70259e2dda2da4e787c63c3abc385c9))
39
+ - eslint package 제거 및 모든 package에 공통 적용되도록 루트에서 적용 ([1d59989](https://github.com/chltjdrhd777/sheet-i18n/commit/1d5998911849dec4d312e4663c966306e5cf48a0))
40
+ - eslint typescript 전역으로 설정되도록 수정 ([8ef2095](https://github.com/chltjdrhd777/sheet-i18n/commit/8ef2095e6fad44650d8179ce0f5408c06bd0ee2e))
41
+ - package 이름 default 값 들어갔던 문제 수정 ([1ef984f](https://github.com/chltjdrhd777/sheet-i18n/commit/1ef984fc03b65a1397ad0d9ef91ab6fcffe58a44))
42
+ - remove auto eslint fix option ([fd35b44](https://github.com/chltjdrhd777/sheet-i18n/commit/fd35b44bd532b13ecff405fbf3f4720a224cbaf0))
43
+ - remove redundant types property in package.json ([2dcde8c](https://github.com/chltjdrhd777/sheet-i18n/commit/2dcde8c004405dd8f3ff72db1c5efd0fc69d08e5))
44
+
45
+ ### [0.1.1](https://github.com/chltjdrhd777/sheet-i18n/compare/v0.1.2...v0.1.1) (2024-12-23)
7
46
 
8
47
  ### Features
9
48
 
10
- * add changelog script in container sheet-18n package ([0f05e47](https://github.com/chltjdrhd777/sheet-i18n/commit/0f05e47dfaa2e6ddc57ff4122f3a09fa8e65f645))
49
+ - add changelog script in container sheet-18n package ([0f05e47](https://github.com/chltjdrhd777/sheet-i18n/commit/0f05e47dfaa2e6ddc57ff4122f3a09fa8e65f645))
package/README.md ADDED
@@ -0,0 +1,189 @@
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
+ This package provides a streamlined way to export data using sheets API. It is designed to simplify the integration of spreadsheet data into your applications, particularly for translation workflows and internationalization (i18n).
129
+
130
+ [Google Sheets API Documentation](https://developers.google.com/sheets/api)<br>
131
+ [Google Auth Library](https://www.npmjs.com/package/google-auth-library)<br>
132
+ [Google Spreadsheet](https://www.npmjs.com/package/google-spreadsheet)
133
+
134
+ ### Exporting Data Format 🗂️
135
+
136
+ 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.
137
+
138
+ </details>
139
+
140
+ <!--
141
+ <details>
142
+ <summary>⚛️ React Component - `sheet-i18n/react`</summary>
143
+
144
+ #### `sheet-i18n/react`
145
+
146
+ 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.
147
+
148
+ ```jsx
149
+ import { useState, useEffect } from 'react';
150
+ import { googleSheetExporter } from 'sheet-i18n/react';
151
+
152
+ const TranslationProvider = ({ children }) => {
153
+ const [translations, setTranslations] = useState({});
154
+
155
+ useEffect(() => {
156
+ const fetchTranslations = async () => {
157
+ const exporter = await googleSheetExporter({
158
+ credentials: {
159
+ sheetId: 'your-google-sheet-id',
160
+ clientEmail: 'your-client-email',
161
+ privateKey: 'your-private-key',
162
+ },
163
+ defaultLocale: 'en',
164
+ });
165
+ const data = await exporter.getTranslations();
166
+ setTranslations(data);
167
+ };
168
+
169
+ fetchTranslations();
170
+ }, []);
171
+
172
+ return (
173
+ <TranslationContext.Provider value={translations}>
174
+ {children}
175
+ </TranslationContext.Provider>
176
+ );
177
+ };
178
+ ```
179
+
180
+ 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.
181
+
182
+ </details>
183
+
184
+ ---
185
+
186
+ ## Additional Notes 📌
187
+
188
+ - **Locales**: Ensure that the first row in your Google Sheet contains the locale headers (e.g., `["ko", "en", "fr"]`).
189
+ - **Placeholders**: Any placeholders within the translation strings will be replaced during the export process. -->
package/package.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
2
  "name": "sheet-i18n",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsup",
9
- "dev": "tsup --watch",
10
- "changelog": "standard-version",
11
- "publish:npm": "npm publish"
12
- },
13
7
  "exports": {
14
8
  "/exporter": {
15
9
  "require": "./dist/exporter/index.js",
@@ -29,11 +23,17 @@
29
23
  },
30
24
  "license": "ISC",
31
25
  "dependencies": {
32
- "@sheet-i18n/exporter": "workspace:*"
26
+ "@sheet-i18n/exporter": "0.1.0"
33
27
  },
34
28
  "devDependencies": {
35
29
  "tsup": "^6.0.0",
36
30
  "typescript": "^5.0.0",
37
- "@sheet-i18n/typescript-config": "workspace:*"
31
+ "@sheet-i18n/typescript-config": "0.1.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "dev": "tsup --watch",
36
+ "changelog": "standard-version",
37
+ "publish:npm": "npm publish"
38
38
  }
39
- }
39
+ }