i18ntk 2.6.0 → 3.1.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/CHANGELOG.md +62 -16
- package/README.md +55 -19
- package/main/i18ntk-sizing.js +471 -218
- package/main/i18ntk-translate.js +833 -0
- package/main/i18ntk-validate.js +26 -14
- package/main/manage/commands/CommandRouter.js +7 -1
- package/main/manage/commands/TranslateCommand.js +463 -0
- package/main/manage/commands/ValidateCommand.js +25 -13
- package/main/manage/index.js +11 -5
- package/package.json +14 -3
- package/settings/settings-cli.js +75 -29
- package/settings/settings-manager.js +109 -1
- package/ui-locales/de.json +5 -2
- package/ui-locales/en.json +5 -2
- package/ui-locales/es.json +5 -2
- package/ui-locales/fr.json +5 -2
- package/ui-locales/ja.json +5 -2
- package/ui-locales/ru.json +7 -4
- package/ui-locales/zh.json +5 -2
- package/utils/config-manager.js +20 -4
- package/utils/security.js +4 -3
- package/utils/translate/api.js +168 -0
- package/utils/translate/cli.js +95 -0
- package/utils/translate/placeholder.js +153 -0
- package/utils/translate/protection.js +243 -0
- package/utils/translate/report.js +117 -0
- package/utils/translate/traverse.js +148 -0
- package/utils/validation-risk.js +175 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.1.0] - 2026-05-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Placeholder-preserve translation mode**: Translates text segments around dynamic placeholders and reinserts the original tokens exactly.
|
|
12
|
+
- **Auto Translate beta settings**: Added settings for placeholder mode, concurrency, batch size, progress interval, retry count, retry delay, timeout, dry-run preview, report output, and BOM output.
|
|
13
|
+
- **Large-file tuning flags**: Added `--batch-size` and `--progress-interval` to `i18ntk-translate`.
|
|
14
|
+
- **Short-lived placeholder manifest**: Mirrors placeholder maps to an OS temp file during processing and removes it after each file completes.
|
|
15
|
+
- **Validation content-risk helper**: Added structured detection for URLs, email addresses, secret-like values, and likely untranslated English content.
|
|
16
|
+
- **Sizing file-set analysis**: Added per-language file counts, per-file sizing statistics, and missing/extra file comparison across locale folders.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Automated and manager Auto Translate flows now default to placeholder `preserve` mode instead of skipping placeholder-bearing strings.
|
|
20
|
+
- `i18ntk-translate` can now be imported and run in-process by other package modules.
|
|
21
|
+
- Source JSON reads tolerate UTF-8 BOM-prefixed files.
|
|
22
|
+
- Validation warnings now report specific issue types and reasons instead of the vague `Risky content` message.
|
|
23
|
+
- English-content validation now reports an English percentage and only warns above a 10% threshold with at least three detected English words.
|
|
24
|
+
- Sizing reports now include folder-level file counts and per-file key/character breakdowns for each language.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- Fixed false-positive validation warnings for normal product copy terms.
|
|
28
|
+
- Fixed validator handling so ordinary explanatory uses of words like `token` or `secret` are not treated as leaked credentials.
|
|
29
|
+
- Fixed distorted `i18ntk-sizing` table output by rendering aligned columns from measured values instead of fixed localized spacing.
|
|
30
|
+
- Fixed sizing language comparison output so it uses analyzed languages and the configured source language baseline.
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
- Removed production `child_process` usage from `main/manage/commands/TranslateCommand.js` by replacing the spawned CLI process with an in-process translator call.
|
|
34
|
+
|
|
35
|
+
## [3.0.0] - 2026-05-05
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- **`i18ntk-translate`**: Zero-dependency CLI tool that converts English source JSON locale files into any target language via Google's free Translate API.
|
|
39
|
+
- **Placeholder protection**: Intelligent detection, masking, and unmasking of dynamic placeholder tokens (`{name}`, `{{count}}`, `%d`, `%s`, `:param`, `{{variable}}`, `%{name}`, `${var}`, etc.) to prevent corruption during translation.
|
|
40
|
+
- **Custom regex support**: `--custom-regex` flag to define additional placeholder patterns for detection and protection.
|
|
41
|
+
- **Interactive control flow**: Two-level user controls — global choice (skip all / send all / ask per key) and per-key interactive mode where each affected key can be individually flagged.
|
|
42
|
+
- **Fully automated CLI mode**: `--no-confirm --skip-placeholders` or `--no-confirm --send-placeholders` flags for unattended CI/CD use.
|
|
43
|
+
- **Post-translation report**: Comprehensive report (stdout, file, or both) listing every skipped key with its original value and a reminder for manual translation.
|
|
44
|
+
- **Multi-file batch processing**: `--source-dir` and `--files` flags support translating all JSON files in a directory at once.
|
|
45
|
+
- **Dry-run mode**: `--dry-run` flag previews which keys would be skipped without making API calls.
|
|
46
|
+
- **UTF-8 BOM output**: `--bom` flag for output files with UTF-8 byte order mark.
|
|
47
|
+
- **Custom translation function**: `--translate-fn` flag to inject an alternative translation API while maintaining the placeholder safety workflow.
|
|
48
|
+
- **Rate-limit handling**: Exponential backoff/retry logic for Google Translate API rate limits and network errors.
|
|
49
|
+
- **Deep JSON traversal**: Full support for nested objects and arrays, preserving data types, null values, and non-string leaf values.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- Version bumped to 3.0.0 (major release with new translation tool feature).
|
|
53
|
+
|
|
8
54
|
## [2.6.0] - 2026-05-03
|
|
9
55
|
|
|
10
56
|
### Security
|
|
@@ -44,22 +90,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
44
90
|
|
|
45
91
|
### Scripts
|
|
46
92
|
- Fixed `scripts/build-public-package.js` and `scripts/reset-release-state.js` `npm_execpath` fallback for missing env var.
|
|
47
|
-
- Fixed `scripts/lint-locales.js` BOM handling and try-catch for `fs.readdirSync`.
|
|
48
|
-
|
|
49
|
-
## [2.5.1] - 2026-04-29
|
|
50
|
-
|
|
51
|
-
### Security
|
|
52
|
-
- Fixed `AdminAuth.verifyPin()` to fail closed when admin config is missing, disabled, or malformed instead of returning success.
|
|
53
|
-
- Fixed auth-required checks to fail closed when settings require admin PIN protection but the admin config is unusable.
|
|
54
|
-
- Normalized admin session expiry handling by storing both `expires` and `expiresAt` and cleaning up both formats consistently.
|
|
55
|
-
|
|
56
|
-
### Added
|
|
57
|
-
- Added regression tests for admin PIN fail-closed behavior and session expiry cleanup.
|
|
58
|
-
|
|
59
|
-
### Changed
|
|
60
|
-
- Documented the public npm package staging flow introduced after `2.5.0`.
|
|
61
|
-
|
|
62
|
-
## [2.5.0] - 2026-04-29
|
|
93
|
+
- Fixed `scripts/lint-locales.js` BOM handling and try-catch for `fs.readdirSync`.
|
|
94
|
+
|
|
95
|
+
## [2.5.1] - 2026-04-29
|
|
96
|
+
|
|
97
|
+
### Security
|
|
98
|
+
- Fixed `AdminAuth.verifyPin()` to fail closed when admin config is missing, disabled, or malformed instead of returning success.
|
|
99
|
+
- Fixed auth-required checks to fail closed when settings require admin PIN protection but the admin config is unusable.
|
|
100
|
+
- Normalized admin session expiry handling by storing both `expires` and `expiresAt` and cleaning up both formats consistently.
|
|
101
|
+
|
|
102
|
+
### Added
|
|
103
|
+
- Added regression tests for admin PIN fail-closed behavior and session expiry cleanup.
|
|
104
|
+
|
|
105
|
+
### Changed
|
|
106
|
+
- Documented the public npm package staging flow introduced after `2.5.0`.
|
|
107
|
+
|
|
108
|
+
## [2.5.0] - 2026-04-29
|
|
63
109
|
|
|
64
110
|
### Security
|
|
65
111
|
- Centralized environment-variable access behind the `utils/env-manager.js` allowlist.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# i18ntk
|
|
1
|
+
# i18ntk v3.1.0
|
|
2
2
|
|
|
3
|
-
Zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, and translation
|
|
3
|
+
Zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, translation completion, automatic locale translation, and runtime translation loading.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -9,27 +9,18 @@ Zero-dependency internationalization toolkit for setup, scanning, analysis, vali
|
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[](https://www.npmjs.com/package/i18ntk)
|
|
11
11
|
[](LICENSE)
|
|
12
|
-
[](https://socket.dev/npm/package/i18ntk/overview/3.1.0)
|
|
13
13
|
|
|
14
14
|
## Upgrade Notice
|
|
15
15
|
|
|
16
|
-
Versions earlier than `
|
|
17
|
-
They are considered unsupported for production use. Upgrade to `
|
|
16
|
+
Versions earlier than `3.1.0` may contain known stability and security issues.
|
|
17
|
+
They are considered unsupported for production use. Upgrade to `3.1.0` or newer.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## v3.1.0 - Auto Translate Hardening and Validation Warning Tuning
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
v3.1.0 improves automatic JSON locale translation through the management menu and the standalone `i18ntk-translate` command. It also reduces noisy validation warnings and added a dedicated settings module for the auto translator.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
- **Security**: Replaced all remaining raw `fs` calls with validated `SecurityUtils` wrappers.
|
|
25
|
-
- **Security**: Fixed path traversal bypass in the fallback `SecurityUtils` implementation.
|
|
26
|
-
- **Security**: Fixed Windows path traversal false negatives (fragile `path.sep` comparison).
|
|
27
|
-
- **Security**: Added `safeUnlinkSync` and `safeRmdirSync` for validated file/directory deletion.
|
|
28
|
-
- **Runtime**: Fixed process event handler leak, missing `setInterval.unref()`, and JSON parse error handling.
|
|
29
|
-
- **TypeScript**: Fixed `BasicI18nRuntime.translate/t` return type from `Promise<string>` to `string`.
|
|
30
|
-
- **Scripts**: Fixed `npm_execpath` fallback in build/release scripts.
|
|
31
|
-
|
|
32
|
-
For the full detailed changelog, see [CHANGELOG.md](./CHANGELOG.md). For migration notes, see [docs/migration-guide-v2.6.0.md](./docs/migration-guide-v2.6.0.md).
|
|
23
|
+
For the full detailed changelog, see [CHANGELOG.md](./CHANGELOG.md). For migration notes, see [docs/migration-guide-v3.1.0.md](./docs/migration-guide-v3.1.0.md).
|
|
33
24
|
|
|
34
25
|
## What i18ntk Does
|
|
35
26
|
|
|
@@ -38,6 +29,7 @@ For the full detailed changelog, see [CHANGELOG.md](./CHANGELOG.md). For migrati
|
|
|
38
29
|
- Translation completeness analysis and usage tracking
|
|
39
30
|
- Validation, sizing, and summary reporting
|
|
40
31
|
- Missing-key completion and fixer workflows
|
|
32
|
+
- Automatic translation of JSON locale files
|
|
41
33
|
- Runtime translation helpers for application code
|
|
42
34
|
- Support for JS/TS, React, Vue, Angular, and generic projects
|
|
43
35
|
|
|
@@ -48,6 +40,7 @@ For the full detailed changelog, see [CHANGELOG.md](./CHANGELOG.md). For migrati
|
|
|
48
40
|
3. Confirm the source language and locale directories.
|
|
49
41
|
4. Run `i18ntk --command=analyze` or `i18ntk --command=validate` to inspect translation coverage.
|
|
50
42
|
5. Use `i18ntk --command=complete` to fill missing keys when needed.
|
|
43
|
+
6. Use `i18ntk --command=translate` or menu option 14 to auto-translate source JSON files.
|
|
51
44
|
|
|
52
45
|
The full onboarding flow is documented in [docs/getting-started.md](docs/getting-started.md).
|
|
53
46
|
|
|
@@ -100,6 +93,7 @@ i18ntk --command=usage
|
|
|
100
93
|
i18ntk --command=scanner
|
|
101
94
|
i18ntk --command=sizing
|
|
102
95
|
i18ntk --command=complete
|
|
96
|
+
i18ntk --command=translate
|
|
103
97
|
i18ntk --command=summary
|
|
104
98
|
```
|
|
105
99
|
|
|
@@ -117,6 +111,7 @@ i18ntk-summary
|
|
|
117
111
|
i18ntk-doctor
|
|
118
112
|
i18ntk-fixer
|
|
119
113
|
i18ntk-backup
|
|
114
|
+
i18ntk-translate
|
|
120
115
|
```
|
|
121
116
|
|
|
122
117
|
Note: `i18ntk --command=backup` in the manager flow is disabled in current builds.
|
|
@@ -133,12 +128,45 @@ Use the standalone `i18ntk-backup` executable when backup operations are require
|
|
|
133
128
|
- `--dry-run`
|
|
134
129
|
- `--help`
|
|
135
130
|
|
|
131
|
+
Auto Translate also supports:
|
|
132
|
+
|
|
133
|
+
- `--source-lang <code>`
|
|
134
|
+
- `--files <pattern>`
|
|
135
|
+
- `--preserve-placeholders`
|
|
136
|
+
- `--skip-placeholders`
|
|
137
|
+
- `--send-placeholders`
|
|
138
|
+
- `--batch-size <n>`
|
|
139
|
+
- `--progress-interval <n>`
|
|
140
|
+
- `--report-file <path>`
|
|
141
|
+
- `--report-stdout`
|
|
142
|
+
|
|
136
143
|
Example:
|
|
137
144
|
|
|
138
145
|
```bash
|
|
139
146
|
i18ntk --command=analyze --source-dir=./src --i18n-dir=./locales --output-dir=./i18ntk-reports
|
|
140
147
|
```
|
|
141
148
|
|
|
149
|
+
## Auto Translate
|
|
150
|
+
|
|
151
|
+
Interactive menu flow:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
i18ntk
|
|
155
|
+
# choose "Auto Translate (Beta)"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Direct CLI examples:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
i18ntk-translate locales/en/common.json de
|
|
162
|
+
i18ntk-translate locales/en/common.json fr --dry-run --report-stdout
|
|
163
|
+
i18ntk-translate locales/en es --files "*.json" --no-confirm --preserve-placeholders
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The manager flow accepts comma- or space-separated target language codes, or `all` for every configured target language. It previews the first target language with a dry run when enabled, asks for confirmation, then writes translated files under matching target-language directories such as `locales/de/common.json`. By default it preserves placeholders while translating the surrounding text.
|
|
167
|
+
|
|
168
|
+
See [docs/auto-translate.md](docs/auto-translate.md) for full usage details.
|
|
169
|
+
|
|
142
170
|
## Runtime API
|
|
143
171
|
|
|
144
172
|
Use `i18ntk/runtime` when your application needs to read locale JSON files at runtime.
|
|
@@ -169,12 +197,18 @@ Example `.i18ntk-config`:
|
|
|
169
197
|
|
|
170
198
|
```json
|
|
171
199
|
{
|
|
172
|
-
"version": "
|
|
200
|
+
"version": "3.1.0",
|
|
173
201
|
"sourceDir": "./locales",
|
|
174
202
|
"i18nDir": "./locales",
|
|
175
203
|
"outputDir": "./i18ntk-reports",
|
|
176
204
|
"sourceLanguage": "en",
|
|
177
205
|
"defaultLanguages": ["de", "es", "fr", "ru"],
|
|
206
|
+
"englishContentThresholdPercent": 10,
|
|
207
|
+
"allowedEnglishTerms": ["BrandName", "PRODUCT_CODE"],
|
|
208
|
+
"autoTranslate": {
|
|
209
|
+
"protectionEnabled": true,
|
|
210
|
+
"protectionFile": "./i18ntk-auto-translate.json"
|
|
211
|
+
},
|
|
178
212
|
"setup": {
|
|
179
213
|
"completed": true
|
|
180
214
|
}
|
|
@@ -190,11 +224,13 @@ See [docs/api/CONFIGURATION.md](docs/api/CONFIGURATION.md) for the full configur
|
|
|
190
224
|
- [API Reference](https://github.com/vladnoskv/i18ntk/blob/main/docs/api/API_REFERENCE.md)
|
|
191
225
|
- [Configuration Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/api/CONFIGURATION.md)
|
|
192
226
|
- [Runtime API Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/runtime.md)
|
|
227
|
+
- [Auto Translate Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/auto-translate.md)
|
|
193
228
|
- [Scanner Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/scanner-guide.md)
|
|
194
229
|
- [Environment Variables](https://github.com/vladnoskv/i18ntk/blob/main/docs/environment-variables.md)
|
|
230
|
+
- [Migration Guide v3.1.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v3.1.0.md)
|
|
231
|
+
- [Migration Guide v3.0.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v3.0.0.md)
|
|
195
232
|
- [Migration Guide v2.6.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.6.0.md)
|
|
196
233
|
- [Migration Guide v2.5.1](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.5.1.md)
|
|
197
|
-
- [Migration Guide v2.5.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.5.0.md)
|
|
198
234
|
|
|
199
235
|
## Community
|
|
200
236
|
|