i18ntk 4.3.3 → 4.4.2
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 +151 -88
- package/README.md +56 -51
- package/main/i18ntk-backup.js +77 -52
- package/main/i18ntk-complete.js +16 -5
- package/main/i18ntk-scanner.js +5 -0
- package/main/i18ntk-translate.js +20 -8
- package/main/i18ntk-usage.js +438 -127
- package/main/manage/commands/TranslateCommand.js +2 -2
- package/package.json +36 -19
- package/utils/config-helper.js +19 -3
- package/utils/english-placeholder-checker.js +15 -2
- package/utils/security.js +49 -6
- package/utils/translate/api.js +16 -1
- package/utils/translate/report.js +26 -2
- package/utils/usage-insights.js +254 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,99 +5,162 @@ 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
|
-
## [4.
|
|
8
|
+
## [4.4.2] - 2026-06-02
|
|
9
9
|
|
|
10
10
|
### Fixed
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- Usage documentation now treats unused-key reports as advisory; do not bulk-delete keys from an unused report without manual verification or a more precise usage scan.
|
|
11
|
+
- Auto Translate `processFile()` now accepts source file paths relative to the current project, matching direct CLI behavior and avoiding safe-read failures in programmatic callers.
|
|
12
|
+
- Auto Translate now treats protected product terms as allowed English when deciding whether existing target values should be kept in `only-missing` mode.
|
|
13
|
+
- Auto Translate detects and retries more visibly broken target values, including replacement-character artifacts, mojibake, repeated question marks, and target-language prefix leftovers.
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
### Added
|
|
16
|
+
- Added regression coverage for relative source paths, protected product terms, broken target values, placeholder handling, and managed Auto Translate residual checks.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- Documentation, README badges, and migration guidance now reference the current 4.3.2 release.
|
|
20
|
-
- Release metadata now marks 4.3.0 for npm deprecation because its npm tarball is unavailable.
|
|
18
|
+
## [4.4.1] - 2026-06-02
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
### Security
|
|
21
|
+
- **HIGH**: Backup operations (`create`, `restore`, `list`, `verify`) now validate all path arguments via `SecurityUtils.validatePath()`. Previously, `i18ntk-backup` accepted arbitrary `--output` and source directory paths without any validation, enabling writes outside project boundaries.
|
|
22
|
+
- **HIGH**: Backup `handleCreate`, `handleRestore` now use `SecurityUtils.safeWriteFileSync`, `safeReadFileSync`, `safeMkdirSync` instead of raw `fs.promises`/`fs` calls.
|
|
23
|
+
- **HIGH**: `i18ntk-complete` now validates `--source-dir` CLI override through `SecurityUtils.validatePath()` and sanitizes `--source-language` through `SecurityUtils.sanitizeInput()` instead of accepting raw user input.
|
|
24
|
+
- **HIGH**: `config-helper` dual-path resolution (when both `--source-dir` and `--i18n-dir` are explicit) now wraps each resolved path in `SecurityUtils.validatePath()`.
|
|
25
|
+
- **MEDIUM**: JSON parsing now enforces maximum depth (1000) and maximum size (50 MB) limits in `safeParseJSON` to prevent denial-of-service via deeply nested or oversized JSON files.
|
|
26
|
+
- **MEDIUM**: LibreTranslate custom URL (`LIBRETRANSLATE_URL`) now requires `I18NTK_ALLOW_CUSTOM_LIBRETRANSLATE_HOST=1` env flag to add arbitrary hosts to the allowed list, bringing parity with DeepL's gated approach.
|
|
27
|
+
- **MEDIUM**: `sanitizeInput` default character whitelist tightened — removed `\\`, `{`, `}` characters that could enable path traversal or template injection.
|
|
28
|
+
- **MEDIUM**: VSCode Workbench `workspaceScanner.ts` now validates auto-translate report paths with `normalizeWithinRoot()` and rejects JSON content > 50 MB.
|
|
29
|
+
- **MEDIUM**: VSCode Workbench `localeFileService.ts` now validates `addKey()` write paths via `isPathWithinRoot()` and rejects locale files > 10 MB before parsing.
|
|
30
|
+
- **LOW**: i18ntk Lens `scanner.ts` now rejects custom wrapper names > 100 characters to prevent ReDoS via malicious VSCode config values.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- `SecurityUtils.MAX_JSON_SIZE`, `SecurityUtils.MAX_JSON_DEPTH`, `SecurityUtils.MAX_FILENAME_LENGTH` constants for configurable safety limits.
|
|
34
|
+
|
|
35
|
+
## [4.4.0] - 2026-06-02
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- Dead-key detection now uses resolved dynamic key data from usage insights instead of crude text-overlap heuristics. Keys expanded from template literals or const arrays are properly tracked and marked with low confidence.
|
|
39
|
+
- Locale JSON import detection: `import en from '../../locales/en/foo.json'` is detected and property accesses are tracked as key usages.
|
|
40
|
+
- Confidence-split unused key reports: confirmed (≥80%), likely (40-80%), possibly used (<40%).
|
|
41
|
+
- `--strict-unused` flag: only reports high-confidence confirmed unused keys.
|
|
42
|
+
- `--json` flag: outputs structured JSON report for automation and CI/CD.
|
|
43
|
+
- `--prune` / `--prune-keep` flags: removes stale report files, keeping N most recent.
|
|
44
|
+
- Mojibake detection: replacement-character artifacts like `Abwicklungspr?fung` and `L?ser` detected during translation analysis.
|
|
45
|
+
- Client-boundary warnings: flags `"use client"` files that import locale JSON, which bypasses i18ntk runtime and increases bundle size.
|
|
46
|
+
- Copy-formatter detection: identifies local `const tx = ...` functions that do not call known translation runtimes.
|
|
47
|
+
- Wrapper configuration: `.i18ntk-config` now supports `usage.translationFunctions`, `usage.serverWrappers`, and `usage.copyFormatters`.
|
|
48
|
+
- Next.js App Router detection: identifies `"use server"` / `"use client"` directives and reports component type.
|
|
49
|
+
- VSCode `i18ntk.clearDiagnostics` command. Stale diagnostics now cleared at scan start.
|
|
50
|
+
- VSCode new diagnostic codes: `i18ntk.clientBoundary` (warning), `i18ntk.copyFormatter` (warning).
|
|
51
|
+
- Lens scanner: `detectSuspectedCopyFormatters()` and `findClientBoundaryLocaleImports()` exported.
|
|
52
|
+
- Auto Translate now writes `i18ntk-reports/auto-translate/latest.json` when residual untranslated values remain after the final targeted retry, so follow-up tooling can retry only unresolved keys.
|
|
53
|
+
- i18ntk Workbench and i18ntk Lens can read Auto Translate residual reports, show the affected key in the VS Code editor, and offer a quick action to add intentionally unchanged keys to Auto Translate protection.
|
|
54
|
+
- Bounded dynamic expansion suggestions in usage report with explicit-map recommendation pattern.
|
|
55
|
+
- Telemetry/event literal classification: known-key strings inside `trackEvent()`, `emitDomainEvent()`, `analytics.track()`, etc. are classified as `literal-telemetry` and excluded from translation usage counts. Non-translation calls get context notes in the report.
|
|
56
|
+
- Object-method translation calls: `input.tx("key")`, `helper.tx("key")`, and `.tx(\`key.${var}\`)` are now recognized as translation calls alongside standalone `tx()`.
|
|
57
|
+
- Local wrapper resolution: functions like `const text = (key, fallback) => tx(key)` that internally call known translation runtimes are detected and their string-literal invocations resolved to keys with `local-wrapper` match type.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
- `--source-dir` and `--i18n-dir` no longer forced to the same value when both are explicitly passed via CLI.
|
|
61
|
+
- Path display (`displayPaths`) now reflects CLI overrides instead of only config file values.
|
|
62
|
+
- Dead-key detection `_matchesDynamicPattern` replaced with `_matchesDynamicPrefix` using actual resolved data.
|
|
63
|
+
- Locale JSON import detection properly deduplicates namespace prefix (e.g., `leaderboard.error` not `leaderboard.leaderboard.error`).
|
|
64
|
+
- Literal key matching no longer credits telemetry/event call strings (e.g., `trackEvent("leaderboard.view")`) as translation usage, preventing CLI false negatives on genuinely unused keys.
|
|
65
|
+
- Object-method `tx()` calls and local wrapper functions are now included in usage analysis, preventing Lens false positives on keys used through these patterns.
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
- VSCode workbench bumped to 1.1.0, lens extension to 1.1.0.
|
|
69
|
+
- Major changes list in package.json and package.public.json updated for 4.4.0.
|
|
70
|
+
|
|
71
|
+
## [4.3.3] - 2026-06-01
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
- Usage extraction no longer reports ordinary method calls such as `get("next")`, `headers.get("etag")`, `set(...)`, or `setItem(...)` as missing translation keys.
|
|
75
|
+
- Usage insights now resolve `tx(...)` wrapper calls and bounded dynamic `tx` template keys, reducing false unused-key reports for local wrappers.
|
|
76
|
+
- Key naming validation now supports hybrid dot-path plus snake_case segment keys, such as `namespace.section.snake_case_leaf`, while still rejecting malformed separators and uppercase segments.
|
|
77
|
+
- Usage documentation now treats unused-key reports as advisory; do not bulk-delete keys from an unused report without manual verification or a more precise usage scan.
|
|
78
|
+
|
|
79
|
+
## [4.3.2] - 2026-05-31
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
- Documentation, README badges, and migration guidance now reference the current 4.3.2 release.
|
|
83
|
+
- Release metadata now marks 4.3.0 for npm deprecation because its npm tarball is unavailable.
|
|
84
|
+
|
|
85
|
+
## [4.3.1] - 2026-05-31
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
25
88
|
- Published tarball now includes `utils/english-placeholder-checker.js`, resolving `MODULE_NOT_FOUND` at startup for `i18ntk-fixer --check-placeholders` and manager option 7.
|
|
26
89
|
- Language-specific CLI entry points (`main/i18ntk-go.js`, `main/i18ntk-java.js`, `main/i18ntk-js.js`, `main/i18ntk-php.js`, `main/i18ntk-py.js`) and their shared `utils/mini-commander.js` dependency are now included in the published package.
|
|
27
90
|
- Removed inconsistent `.js` extension suffixes from require paths in `main/i18ntk-js.js`.
|
|
28
91
|
|
|
29
|
-
## [4.3.0] - 2026-05-31
|
|
30
|
-
|
|
31
|
-
### Fixed
|
|
32
|
-
- Auto Translate now treats single-word uppercase target-language placeholders such as `[AR] Email` and `[AR] Password` as untranslated target values, matching the existing multi-word `[AR] What We Offer` detection.
|
|
33
|
-
- Auto Translate now treats bracketed target-language placeholders case-insensitively, so `[zh] Email` and `[TR] Password` are both retried for the matching target language.
|
|
34
|
-
- Managed Auto Translate now checks every selected source file for a target language before reporting leftover failures, instead of stopping after the first failed file.
|
|
35
|
-
- Auto Translate no longer fails a run when a provider legitimately returns a short all-caps acronym or code unchanged, such as `XP`.
|
|
36
|
-
- Manager option 7 and `i18ntk-fixer --check-placeholders` now run an English source placeholder audit, reporting any `[LANG] ...` values left in English locale files; a clean project reports `0` placeholders.
|
|
37
|
-
- The management command router no longer prints a generic operation-success message when a command returns `{ success: false }`.
|
|
38
|
-
|
|
39
|
-
## [4.2.1] - 2026-05-31
|
|
40
|
-
|
|
41
|
-
### Changed
|
|
42
|
-
- Auto Translate now treats uppercase target-language placeholders such as `[AR] What We Offer` as untranslated target values when the bracketed code matches the target language, so target-aware mode sends the source text for translation instead of keeping the placeholder copy.
|
|
43
|
-
- Auto Translate now performs a final pre-write leftover check and retries values that still look like placeholder-prefixed untranslated text, untranslated markers, source-language copies, or broken output.
|
|
44
|
-
- Auto Translate reports leftover values in the post-translation report and exits with validation failure when leftovers remain after the final retry, instead of reporting a clean completion.
|
|
45
|
-
|
|
46
|
-
### Fixed
|
|
47
|
-
- Usage analysis no longer writes its inferred app source fallback, such as `src`, back into the shared locale configuration when `sourceDir` and `i18nDir` are both the locale directory.
|
|
48
|
-
- Manager sizing now reads the configured i18n directory unless `--source-dir` is explicitly provided, so running sizing after usage no longer silently analyzes the wrong directory.
|
|
49
|
-
- Manager sizing now treats a failed sizing analysis as a command failure instead of printing a generic operation success.
|
|
50
|
-
- Validation summary reports now include warning and error details, including content-risk warning payloads, instead of only totals.
|
|
51
|
-
|
|
52
|
-
## [4.2.0] - 2026-05-30
|
|
53
|
-
|
|
54
|
-
### Security
|
|
55
|
-
- Shared path validation no longer permits artifact-like filenames such as `.lock` or `.temp-config.json` to bypass base-directory containment.
|
|
56
|
-
- Shared path validation now rejects Windows cross-drive escape cases where `path.relative()` returns an absolute path.
|
|
57
|
-
- Custom `I18NTK_INTERNAL_PATH_PREFIXES` entries can no longer mark arbitrary outside directories as internal roots.
|
|
58
|
-
- Backup restore now rejects backup entry names containing path separators, absolute paths, traversal, or non-JSON names before writing restored files.
|
|
59
|
-
- Runtime locale loading now validates language identifiers before resolving single-file or directory locale paths, blocking `../` language names from reading JSON outside `baseDir`.
|
|
60
|
-
- Auto Translate provider URL validation now blocks IPv4-mapped IPv6 loopback/private hosts.
|
|
61
|
-
|
|
62
|
-
### Changed
|
|
63
|
-
- Main runtime now includes production-safe features from the enhanced runtime surface: per-call language overrides, synchronous `translateBatch()`, and `clearCache()` / `getCacheInfo()` helpers.
|
|
64
|
-
- `i18ntk/runtime/enhanced` remains available as a legacy public subpath for compatibility, while new production integrations should prefer the lightweight `i18ntk/runtime` API.
|
|
65
|
-
- Usage analysis now indexes known translation keys back to source files, including direct i18n calls and literal key references that were previously missed.
|
|
66
|
-
- Usage analysis now expands simple dynamic templates backed by literal constants, bounded literal arrays, object maps, and ternaries to exact available keys before falling back to unresolved dynamic-expression reporting.
|
|
67
|
-
- Usage reports now list unresolved dynamic key expressions separately instead of treating broad wildcard prefixes as proof that every matching key is used.
|
|
68
|
-
- Usage reports now include namespace/file naming recommendations such as preferring `shop.*` keys and `shop.json` for `/shop` page or route files.
|
|
69
|
-
- Usage reports now list likely hardcoded user-facing text with suggested translation keys, and prefer an existing source key when the inline text matches a source translation value.
|
|
70
|
-
- Translation analysis and init reports now default to Markdown for readable output, with `reports.format` supporting `markdown`, `json`, or `text` through settings and config.
|
|
71
|
-
- Init default target languages now include English (`en`) before `de`, `es`, `fr`, and `ru` when the UI is running in another language.
|
|
72
|
-
- Confirmation prompts now accept localized native yes/no input for supported UI languages while retaining English fallback tokens.
|
|
73
|
-
- Auto Translate has moved out of beta in menus and documentation, and its settings are exposed with localized labels.
|
|
74
|
-
- Auto Translate now keeps existing translated target values by default and only translates missing, marker, source-copy, or likely English target strings; use `--translate-all` to force a full re-translation.
|
|
75
|
-
- Auto Translate now treats visibly corrupt target strings such as `?????`, Unicode replacement characters, and common mojibake as needing retranslation from the source language.
|
|
76
|
-
- Auto Translate now defaults to 12 concurrent provider requests and allows Google concurrency up to 100 instead of the old 25-request cap; DeepL and LibreTranslate remain capped lower to avoid provider/account throttling.
|
|
77
|
-
- Auto Translate progress output now separates string translation from placeholder-safe text-segment translation and shows the active key path during progress updates.
|
|
78
|
-
- Placeholder detection now covers ICU plural/select blocks, i18next nested `$t(...)` references, and wider named printf formats such as `%(total).2f`.
|
|
79
|
-
- Manager menu output is now grouped with clearer spacing and aligned option numbers.
|
|
80
|
-
- Documentation now consolidates migration guidance around `4.2.0` and removes stale old per-version migration guides from the working docs tree.
|
|
81
|
-
- Removed stale duplicate development artifacts `main/manage/index-fixed.js` and `utils/security-fixed.js` to reduce audit drift and prevent accidental reuse.
|
|
82
|
-
- Updated public, root, and development package metadata for the 4.2.0 release line.
|
|
83
|
-
|
|
84
|
-
### Fixed
|
|
85
|
-
- Runtime JSON loading now preserves valid translation strings containing comment-like text such as `/* token */` by parsing valid JSON before using the comment-stripping fallback.
|
|
86
|
-
- Enhanced runtime now exports the top-level `translateBatch()`, `translateBatchEncrypted()`, and `tTyped()` helpers declared by its TypeScript definitions, and those declarations now reflect async return values.
|
|
87
|
-
- Usage analysis no longer scans the project root when `sourceDir` and `i18nDir` both point at the locale directory; it now uses a detected app source directory or disables usage scanning with a clear warning.
|
|
88
|
-
- Init backup prompts, completion summaries, report prompts, and report status text now use bundled UI locale keys instead of hard-coded English.
|
|
89
|
-
- Bundled UI locales were regenerated from `ui-locales/en.json` for newly added, source-copy, and corrupt target strings.
|
|
90
|
-
- JSON report output is now pretty-printed object JSON instead of a single JSON string containing escaped newlines.
|
|
91
|
-
- The managed Auto Translate command no longer forces UI translations back to English after the user has selected another UI language.
|
|
92
|
-
- Manager validation output no longer prints duplicate source/i18n/output directory blocks before the validator summary.
|
|
93
|
-
- `i18ntk-setup --help` now exits after printing help instead of running setup and writing project files.
|
|
94
|
-
- `npm run languages:list` and `npm run languages:status` now produce non-interactive output instead of opening the settings menu.
|
|
95
|
-
- `i18ntk-backup create locales` now recursively backs up modular locale layouts such as `locales/en/common.json`, and restore safely recreates nested JSON paths without allowing traversal.
|
|
96
|
-
- Removed a stale bundled `locales/es/navigation.json` fixture that made `i18ntk-doctor` report a dangling namespace after setup/init tests.
|
|
97
|
-
|
|
98
|
-
## [4.1.0] - 2026-05-21
|
|
99
|
-
|
|
100
|
-
### Fixed
|
|
92
|
+
## [4.3.0] - 2026-05-31
|
|
93
|
+
|
|
94
|
+
### Fixed
|
|
95
|
+
- Auto Translate now treats single-word uppercase target-language placeholders such as `[AR] Email` and `[AR] Password` as untranslated target values, matching the existing multi-word `[AR] What We Offer` detection.
|
|
96
|
+
- Auto Translate now treats bracketed target-language placeholders case-insensitively, so `[zh] Email` and `[TR] Password` are both retried for the matching target language.
|
|
97
|
+
- Managed Auto Translate now checks every selected source file for a target language before reporting leftover failures, instead of stopping after the first failed file.
|
|
98
|
+
- Auto Translate no longer fails a run when a provider legitimately returns a short all-caps acronym or code unchanged, such as `XP`.
|
|
99
|
+
- Manager option 7 and `i18ntk-fixer --check-placeholders` now run an English source placeholder audit, reporting any `[LANG] ...` values left in English locale files; a clean project reports `0` placeholders.
|
|
100
|
+
- The management command router no longer prints a generic operation-success message when a command returns `{ success: false }`.
|
|
101
|
+
|
|
102
|
+
## [4.2.1] - 2026-05-31
|
|
103
|
+
|
|
104
|
+
### Changed
|
|
105
|
+
- Auto Translate now treats uppercase target-language placeholders such as `[AR] What We Offer` as untranslated target values when the bracketed code matches the target language, so target-aware mode sends the source text for translation instead of keeping the placeholder copy.
|
|
106
|
+
- Auto Translate now performs a final pre-write leftover check and retries values that still look like placeholder-prefixed untranslated text, untranslated markers, source-language copies, or broken output.
|
|
107
|
+
- Auto Translate reports leftover values in the post-translation report and exits with validation failure when leftovers remain after the final retry, instead of reporting a clean completion.
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
- Usage analysis no longer writes its inferred app source fallback, such as `src`, back into the shared locale configuration when `sourceDir` and `i18nDir` are both the locale directory.
|
|
111
|
+
- Manager sizing now reads the configured i18n directory unless `--source-dir` is explicitly provided, so running sizing after usage no longer silently analyzes the wrong directory.
|
|
112
|
+
- Manager sizing now treats a failed sizing analysis as a command failure instead of printing a generic operation success.
|
|
113
|
+
- Validation summary reports now include warning and error details, including content-risk warning payloads, instead of only totals.
|
|
114
|
+
|
|
115
|
+
## [4.2.0] - 2026-05-30
|
|
116
|
+
|
|
117
|
+
### Security
|
|
118
|
+
- Shared path validation no longer permits artifact-like filenames such as `.lock` or `.temp-config.json` to bypass base-directory containment.
|
|
119
|
+
- Shared path validation now rejects Windows cross-drive escape cases where `path.relative()` returns an absolute path.
|
|
120
|
+
- Custom `I18NTK_INTERNAL_PATH_PREFIXES` entries can no longer mark arbitrary outside directories as internal roots.
|
|
121
|
+
- Backup restore now rejects backup entry names containing path separators, absolute paths, traversal, or non-JSON names before writing restored files.
|
|
122
|
+
- Runtime locale loading now validates language identifiers before resolving single-file or directory locale paths, blocking `../` language names from reading JSON outside `baseDir`.
|
|
123
|
+
- Auto Translate provider URL validation now blocks IPv4-mapped IPv6 loopback/private hosts.
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
- Main runtime now includes production-safe features from the enhanced runtime surface: per-call language overrides, synchronous `translateBatch()`, and `clearCache()` / `getCacheInfo()` helpers.
|
|
127
|
+
- `i18ntk/runtime/enhanced` remains available as a legacy public subpath for compatibility, while new production integrations should prefer the lightweight `i18ntk/runtime` API.
|
|
128
|
+
- Usage analysis now indexes known translation keys back to source files, including direct i18n calls and literal key references that were previously missed.
|
|
129
|
+
- Usage analysis now expands simple dynamic templates backed by literal constants, bounded literal arrays, object maps, and ternaries to exact available keys before falling back to unresolved dynamic-expression reporting.
|
|
130
|
+
- Usage reports now list unresolved dynamic key expressions separately instead of treating broad wildcard prefixes as proof that every matching key is used.
|
|
131
|
+
- Usage reports now include namespace/file naming recommendations such as preferring `shop.*` keys and `shop.json` for `/shop` page or route files.
|
|
132
|
+
- Usage reports now list likely hardcoded user-facing text with suggested translation keys, and prefer an existing source key when the inline text matches a source translation value.
|
|
133
|
+
- Translation analysis and init reports now default to Markdown for readable output, with `reports.format` supporting `markdown`, `json`, or `text` through settings and config.
|
|
134
|
+
- Init default target languages now include English (`en`) before `de`, `es`, `fr`, and `ru` when the UI is running in another language.
|
|
135
|
+
- Confirmation prompts now accept localized native yes/no input for supported UI languages while retaining English fallback tokens.
|
|
136
|
+
- Auto Translate has moved out of beta in menus and documentation, and its settings are exposed with localized labels.
|
|
137
|
+
- Auto Translate now keeps existing translated target values by default and only translates missing, marker, source-copy, or likely English target strings; use `--translate-all` to force a full re-translation.
|
|
138
|
+
- Auto Translate now treats visibly corrupt target strings such as `?????`, Unicode replacement characters, and common mojibake as needing retranslation from the source language.
|
|
139
|
+
- Auto Translate now defaults to 12 concurrent provider requests and allows Google concurrency up to 100 instead of the old 25-request cap; DeepL and LibreTranslate remain capped lower to avoid provider/account throttling.
|
|
140
|
+
- Auto Translate progress output now separates string translation from placeholder-safe text-segment translation and shows the active key path during progress updates.
|
|
141
|
+
- Placeholder detection now covers ICU plural/select blocks, i18next nested `$t(...)` references, and wider named printf formats such as `%(total).2f`.
|
|
142
|
+
- Manager menu output is now grouped with clearer spacing and aligned option numbers.
|
|
143
|
+
- Documentation now consolidates migration guidance around `4.2.0` and removes stale old per-version migration guides from the working docs tree.
|
|
144
|
+
- Removed stale duplicate development artifacts `main/manage/index-fixed.js` and `utils/security-fixed.js` to reduce audit drift and prevent accidental reuse.
|
|
145
|
+
- Updated public, root, and development package metadata for the 4.2.0 release line.
|
|
146
|
+
|
|
147
|
+
### Fixed
|
|
148
|
+
- Runtime JSON loading now preserves valid translation strings containing comment-like text such as `/* token */` by parsing valid JSON before using the comment-stripping fallback.
|
|
149
|
+
- Enhanced runtime now exports the top-level `translateBatch()`, `translateBatchEncrypted()`, and `tTyped()` helpers declared by its TypeScript definitions, and those declarations now reflect async return values.
|
|
150
|
+
- Usage analysis no longer scans the project root when `sourceDir` and `i18nDir` both point at the locale directory; it now uses a detected app source directory or disables usage scanning with a clear warning.
|
|
151
|
+
- Init backup prompts, completion summaries, report prompts, and report status text now use bundled UI locale keys instead of hard-coded English.
|
|
152
|
+
- Bundled UI locales were regenerated from `ui-locales/en.json` for newly added, source-copy, and corrupt target strings.
|
|
153
|
+
- JSON report output is now pretty-printed object JSON instead of a single JSON string containing escaped newlines.
|
|
154
|
+
- The managed Auto Translate command no longer forces UI translations back to English after the user has selected another UI language.
|
|
155
|
+
- Manager validation output no longer prints duplicate source/i18n/output directory blocks before the validator summary.
|
|
156
|
+
- `i18ntk-setup --help` now exits after printing help instead of running setup and writing project files.
|
|
157
|
+
- `npm run languages:list` and `npm run languages:status` now produce non-interactive output instead of opening the settings menu.
|
|
158
|
+
- `i18ntk-backup create locales` now recursively backs up modular locale layouts such as `locales/en/common.json`, and restore safely recreates nested JSON paths without allowing traversal.
|
|
159
|
+
- Removed a stale bundled `locales/es/navigation.json` fixture that made `i18ntk-doctor` report a dangling namespace after setup/init tests.
|
|
160
|
+
|
|
161
|
+
## [4.1.0] - 2026-05-21
|
|
162
|
+
|
|
163
|
+
### Fixed
|
|
101
164
|
- Runtime: stale manifest entries (deleted files after manifest construction) no longer cause unhandled exceptions; loadedFiles set before load with try/catch guard.
|
|
102
165
|
- Runtime: `refresh()` now correctly clears the key manifest for the refreshed language, preventing stale file references.
|
|
103
166
|
- Runtime: null `baseDir` guard prevents cascading `validatePath(null)` errors in `loadKeyManifestFromDir`.
|
|
@@ -135,20 +198,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
135
198
|
- Public package metadata updated.
|
|
136
199
|
|
|
137
200
|
### Security
|
|
138
|
-
- Watch module: debounce timers properly cleaned up on stop and callback subscriptions corrected for object-format and unlink handlers.
|
|
201
|
+
- Watch module: debounce timers properly cleaned up on stop and callback subscriptions corrected for object-format and unlink handlers.
|
|
139
202
|
- Runtime: loadedFiles lock-before-load pattern prevents duplicate I/O and stale manifest crash.
|
|
140
203
|
- Backup: circular parent reference detection; `--incremental=false` string truthy bypass closed.
|
|
141
204
|
- Sizing: adminAuth variable reference corrected; require()-time `process.exit()` guarded.
|
|
142
205
|
- Scanner: vanilla framework key prevents `undefined` return; stopword-less validRatio enforced.
|
|
143
206
|
- Usage: O(n+m) comment scanning prevents DoS via large codebase with many dead keys; `toBool()` prevents flag injection.
|
|
144
207
|
- Validator: try/catch pairing restored; `flat` leaf-segment prevents false-positive flood.
|
|
145
|
-
- Protection: Unicode-aware punctuation boundaries for CJK/Cyrillic/Arabic; standalone boundaries include the expanded punctuation set.
|
|
208
|
+
- Protection: Unicode-aware punctuation boundaries for CJK/Cyrillic/Arabic; standalone boundaries include the expanded punctuation set.
|
|
146
209
|
|
|
147
210
|
## [4.0.0] - 2026-05-21
|
|
148
211
|
|
|
149
212
|
### Added
|
|
150
213
|
- **Sizing Expansion Prediction**: `i18ntk-sizing` now supports `--predict-expansion` flag that computes per-key character-count expansion ratios across languages and classifies them into Safe/Warning/Critical risk tiers for UI layout planning. Includes a built-in language-pair expansion reference table (EN→DE 35%, EN→RU 50%, EN→JA -40%, etc.).
|
|
151
|
-
- **Watch Hot Reload**: `utils/watch-locales.js` rewritten as an EventEmitter-compatible watcher with debouncing (300ms default) and SHA-256 hash tracking to skip no-change saves. Returns a callable watcher object with `change`, `add`, `unlink`, `error` events and `stop()`.
|
|
214
|
+
- **Watch Hot Reload**: `utils/watch-locales.js` rewritten as an EventEmitter-compatible watcher with debouncing (300ms default) and SHA-256 hash tracking to skip no-change saves. Returns a callable watcher object with `change`, `add`, `unlink`, `error` events and `stop()`.
|
|
152
215
|
- **Usage Dead Key Detection**: `i18ntk-usage` adds `--cleanup` and `--dry-run-delete` flags that identify unused translation keys with confidence scores (0.0–1.0) factoring dynamic access patterns, comment references, and file recency. Produces a `.dead-keys.json` report for safe review before deletion.
|
|
153
216
|
- **Validator Key Naming Convention**: `i18ntk-validate` adds `--enforce-key-style` flag and `keyStyle` config setting supporting `dot.notation`, `snake_case`, `camelCase`, `kebab-case`, and `flat` conventions. Reports all violating keys with suggested canonical forms.
|
|
154
217
|
- **Scanner Multi-Language Detection**: `i18ntk-scanner` adds `--source-language` flag with character-class profiles for 12+ languages (English, German, French, Spanish, Japanese, Chinese, Russian, Korean, Arabic, Hindi, etc.). Language-specific stopword lists and key generation with transliteration for non-Latin scripts.
|
|
@@ -159,7 +222,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
159
222
|
### Fixed
|
|
160
223
|
- `i18ntk/runtime` `initRuntime()` now returns independent runtime instances with separate language, fallback language, base directory, and cache state. Later `initRuntime()` calls no longer overwrite earlier returned runtimes or the module-level compatibility singleton.
|
|
161
224
|
|
|
162
|
-
### Changed
|
|
225
|
+
### Changed
|
|
163
226
|
- `watchLocales()` now returns a callable watcher object with EventEmitter methods instead of only a bare `stop` function. Existing `const stop = watchLocales(...); stop();` usage remains supported. The returned object fires `change`, `add`, `unlink`, `error` events. If a callback function is passed as the second argument, it is auto-subscribed to `change` and `add` for backward compatibility.
|
|
164
227
|
- **BREAKING**: `i18ntk-sizing` JSON reports now include `expansionPredictions` at the top level when `--predict-expansion` is used. This field is additive — existing report fields are preserved.
|
|
165
228
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# i18ntk v4.
|
|
1
|
+
# i18ntk v4.4.2
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, translation completion, automatic JSON locale translation, reporting, and runtime translation loading.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -9,19 +9,11 @@ A i18n toolkit - A zero-dependency internationalization toolkit for setup, scann
|
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[](https://www.npmjs.com/package/i18ntk)
|
|
11
11
|
[](LICENSE)
|
|
12
|
-
[](https://socket.dev/npm/package/i18ntk/overview/4.4.2)
|
|
14
13
|
|
|
15
14
|
[](https://marketplace.visualstudio.com/items?itemName=VladNoskov.i18ntk-workbench)
|
|
16
15
|
[](https://marketplace.visualstudio.com/items?itemName=VladNoskov.i18ntk-lens)
|
|
17
16
|
|
|
18
|
-
Official VS Code extensions powered by i18ntk:
|
|
19
|
-
|
|
20
|
-
- **i18ntk Workbench**: setup, scanning, validation, usage checks, reports, key management, and CLI-backed Auto Translate inside VS Code.
|
|
21
|
-
- **i18ntk Lens**: lightweight inline hovers, CodeLens, missing-key warnings, unused-key diagnostics, key navigation, and settings.
|
|
22
|
-
|
|
23
|
-
Install both when you want the full sidebar plus inline editor feedback.
|
|
24
|
-
|
|
25
17
|
## Install
|
|
26
18
|
|
|
27
19
|
```bash
|
|
@@ -35,59 +27,72 @@ npm install --save-dev i18ntk
|
|
|
35
27
|
npx i18ntk --help
|
|
36
28
|
```
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- Node.js `>=16.0.0`
|
|
41
|
-
- npm `>=8.0.0`
|
|
42
|
-
- No runtime dependencies
|
|
30
|
+
## i18ntk Summary
|
|
43
31
|
|
|
44
|
-
|
|
32
|
+
**What it does**
|
|
45
33
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
34
|
+
- Manages locale files from the command line.
|
|
35
|
+
- Finds missing, unused, risky, and inconsistent translation keys.
|
|
36
|
+
- Produces validation and summary reports.
|
|
37
|
+
- Supports framework-aware i18n workflows.
|
|
38
|
+
- Provides a lightweight runtime translation toolkit.
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
**What it does not do**
|
|
52
41
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
42
|
+
- It is not a translation management SaaS.
|
|
43
|
+
- It does not replace human translation review.
|
|
44
|
+
- It does not force you to replace i18next, react-i18next, vue-i18n, or another runtime.
|
|
55
45
|
|
|
56
|
-
|
|
46
|
+
**Why not i18next?**
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
- **FIX**: Language-specific CLI entry points (`i18ntk-go`, `i18ntk-java`, `i18ntk-js`, `i18ntk-php`, `i18ntk-py`) and their shared `utils/mini-commander.js` dependency are now included in the published package.
|
|
60
|
-
- **FIX**: Removed inconsistent `.js` extension suffixes from require paths in `main/i18ntk-js.js`.
|
|
48
|
+
i18next is mainly a runtime internationalization library. i18ntk is mainly workflow tooling around translation files. They can work together: i18next handles runtime translation, while i18ntk handles setup, scanning, validation, reporting, and maintenance.
|
|
61
49
|
|
|
62
|
-
|
|
50
|
+
| Need | i18ntk | i18next |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| Runtime translation | Basic toolkit | Mature runtime |
|
|
53
|
+
| Locale file scanning | Yes | No |
|
|
54
|
+
| Missing key detection | Yes | No |
|
|
55
|
+
| Unused key detection | Yes | No |
|
|
56
|
+
| Validation reports | Yes | Limited |
|
|
57
|
+
| Auto-translation workflow | Yes | External tooling |
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
- **AUTO TRANSLATE**: Before writing each output file, Auto Translate now performs a final leftover check and retries any placeholder-prefixed or source-copy values once.
|
|
66
|
-
- **AUTO TRANSLATE**: If leftovers remain after the final retry, the command warns, includes them in the report, recommends rerunning Auto Translate, and exits with validation failure instead of reporting a clean completion.
|
|
67
|
-
- **AUTO TRANSLATE**: Managed Auto Translate now checks every selected source file for a target language before reporting leftovers, so one failed file does not prevent the rest from being audited.
|
|
68
|
-
- **AUTO TRANSLATE**: Short all-caps acronyms and codes such as `XP` are allowed to remain unchanged instead of failing the final leftover check.
|
|
69
|
-
- **FIX PLACEHOLDERS**: Menu option 7 now runs an English source placeholder audit and reports how many `[LANG] ...` values remain in English locale files. A clean project reports `0`.
|
|
70
|
-
- **SIZING/USAGE**: Usage analysis no longer writes its inferred app source fallback back into the shared locale config, so running usage before sizing no longer makes sizing analyze the wrong directory.
|
|
71
|
-
- **VALIDATION REPORTS**: Validation summary files now include warning and error details, including English-content warning payloads, instead of only totals.
|
|
72
|
-
- **DOCS**: Versioned docs and migration guidance now reflect the current 4.3.0 command surface.
|
|
59
|
+
## What's New in 4.4.2
|
|
73
60
|
|
|
74
|
-
|
|
61
|
+
- **AUTO TRANSLATE RELATIVE PATHS**: Programmatic `processFile()` calls now accept project-relative source paths, matching CLI source resolution.
|
|
62
|
+
- **PROTECTED TERMS IN ONLY-MISSING MODE**: Existing translations that intentionally keep protected product terms such as `i18ntk` are no longer treated as English leftovers.
|
|
63
|
+
- **BROKEN TARGET RETRIES**: Auto Translate now detects and retries more visibly broken target values, including mojibake, replacement characters, repeated question marks, and target-language prefix leftovers.
|
|
64
|
+
- **REGRESSION COVERAGE**: Added focused tests for relative paths, protected product terms, broken values, placeholder handling, and residual checks.
|
|
75
65
|
|
|
76
|
-
|
|
66
|
+
## What's New in 4.4.1
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
- **DEAD-KEY DETECTION**: Dead-key confidence now uses resolved dynamic key data from usage insights instead of crude text-overlap heuristics. Keys expanded from template literals or const arrays are properly tracked.
|
|
69
|
+
- **LOCALE JSON IMPORT DETECTION**: `import en from '../../locales/en/foo.json'` is now detected and property accesses are tracked as key usages, closing the gap between CLI and VSCode scanners.
|
|
70
|
+
- **CONFIDENCE-SPLIT REPORTS**: Unused keys are now reported by confidence tier — confirmed (≥80%), likely (40-80%), possibly used (<40%) — instead of a flat list.
|
|
71
|
+
- **NEW CLI FLAGS**: `--strict-unused` (only high-confidence keys), `--json` (structured JSON output for CI), `--prune` / `--prune-keep` (stale report cleanup).
|
|
72
|
+
- **MOJIBAKE DETECTION**: Replacement-character artifacts like `Abwicklungspr?fung` and `L?ser` are detected during translation analysis.
|
|
73
|
+
- **CLIENT-BOUNDARY WARNINGS**: `"use client"` files importing locale JSON are flagged — this bypasses the runtime and increases bundle size.
|
|
74
|
+
- **COPY-FORMATTER DETECTION**: Local `const tx = ...` functions that don't call a translation runtime are identified as likely copy formatters, reducing false positive key noise.
|
|
75
|
+
- **CONFIG FIX**: `--source-dir` and `--i18n-dir` are no longer forced equal when both are explicitly passed via CLI.
|
|
76
|
+
- **Next.js DETECTION**: App Router files with `"use server"` / `"use client"` directives are now detected and reported by component type.
|
|
77
|
+
- **VSCode DIAGNOSTICS**: New `i18ntk.clearDiagnostics` command. Stale diagnostics are now cleared at scan start. New diagnostic codes: `i18ntk.clientBoundary`, `i18ntk.copyFormatter`.
|
|
78
|
+
- **AUTO TRANSLATE RESUME REPORTS**: If a provider still returns untranslated values after the final targeted retry, Auto Translate writes `i18ntk-reports/auto-translate/latest.json` so tooling can identify and retry only unresolved keys.
|
|
79
|
+
- **VS CODE RESIDUAL PICKUP**: i18ntk Workbench and Lens read Auto Translate residual reports, show the affected locale JSON key in the editor, and can add intentionally unchanged keys to Auto Translate protection.
|
|
80
|
+
- **WRAPPER CONFIG**: `.i18ntk-config` now supports `usage.translationFunctions`, `usage.serverWrappers`, and `usage.copyFormatters` for fine-grained control.
|
|
81
|
+
- **TELEMETRY/EVENT STRING FILTERING**: String literals inside `trackEvent()`, `emitDomainEvent()`, `analytics.track()` and similar calls are classified as telemetry literals and no longer falsely counted as translation usage.
|
|
82
|
+
- **OBJECT-METHOD KEY DETECTION**: input.tx("key"), helper.tx("key"), and .tx(\`dynamic.${var}\`) patterns are now recognized as translation calls alongside standalone `tx()` calls.
|
|
79
83
|
|
|
80
|
-
- **
|
|
81
|
-
- **WATCH**: `watchLocales()` now returns an EventEmitter-compatible watcher with debounced `change`/`add`/`unlink`/`error` events and SHA-256 hash tracking.
|
|
82
|
-
- **USAGE**: `--cleanup` and `--dry-run-delete` flags identify dead translation keys with confidence scores.
|
|
83
|
-
- **VALIDATOR**: `--enforce-key-style` enforces dot.notation, snake_case, camelCase, kebab-case, or flat naming conventions.
|
|
84
|
-
- **SCANNER**: `--source-language` supports multi-language hardcoded text detection with 12+ language profiles.
|
|
85
|
-
- **BACKUP**: `--incremental` flag creates differential backups with SHA-256 hashing and chained restores.
|
|
86
|
-
- **RUNTIME**: `lazy: true` option defers locale file loading until first key access for lower memory usage.
|
|
87
|
-
- **PROTECTION**: Context-aware rules (`after:word`, `before:word`, `standalone`, `surrounded:left,right`) for precise term masking.
|
|
84
|
+
- **LOCAL WRAPPER RESOLUTION**: Functions like `const text = (key, fallback) => tx(key)` that internally call the translation runtime are detected, and their string-literal invocations are automatically resolved to actual keys.
|
|
88
85
|
|
|
89
86
|
See [CHANGELOG.md](./CHANGELOG.md) for more release details.
|
|
90
87
|
|
|
88
|
+
## Security hardening in 4.4.1
|
|
89
|
+
|
|
90
|
+
- **PATH TRAVERSAL HARDENED**: Backup, complete, and config-helper commands now validate all user-supplied paths through `SecurityUtils.validatePath()`, blocking writes outside project boundaries.
|
|
91
|
+
- **JSON DoS PREVENTED**: `safeParseJSON` enforces maximum depth (1000) and maximum size (50 MB) before parsing, preventing denial-of-service via deeply nested or oversized JSON.
|
|
92
|
+
- **INPUT SANITIZATION TIGHTENED**: `sanitizeInput` default whitelist no longer allows backslashes or curly braces that could enable path traversal or template injection.
|
|
93
|
+
|
|
94
|
+
- **LIBRETRANSLATE URL GATED**: Custom LibreTranslate host now requires `I18NTK_ALLOW_CUSTOM_LIBRETRANSLATE_HOST=1` env flag (parity with DeepL).
|
|
95
|
+
|
|
91
96
|
## Quick Start
|
|
92
97
|
|
|
93
98
|
Initialize a project:
|
|
@@ -173,7 +178,7 @@ Note: manager route `i18ntk --command=backup` is disabled in current builds. Use
|
|
|
173
178
|
| `i18ntk --command=usage` / `i18ntk-usage` | Maps translation keys to source files and finds unused/missing keys. | Direct i18n calls, literal known-key references, bounded dynamic templates/object maps, unresolved dynamic expressions, hardcoded text candidates, namespace/file naming mismatches. | Usage report with key locations, namespace recommendations, unresolved dynamic expressions, hardcoded text suggestions, and optional dead-key report. Does not delete unless cleanup deletion is explicitly enabled. |
|
|
174
179
|
| `i18ntk --command=scanner` / `i18ntk-scanner` | Scans source for i18n issues and hardcoded user-facing text. | JSX/template text, common text attributes, i18n usage patterns, source-language text profiles. | Scanner report. Does not edit files. |
|
|
175
180
|
| `i18ntk --command=complete` / `i18ntk-complete` | Adds missing keys to target language files for 100% key coverage. | Source-language keys missing from targets. | Target locale JSON files, using missing translation markers/prefixes. |
|
|
176
|
-
| `i18ntk --command=translate` / `i18ntk-translate` | Auto-translates locale JSON using configured provider behavior. | Missing, empty, untranslated-marker, source-copy, likely-English, or visibly corrupt target values by default. | Target locale JSON files and translation reports. Existing translated values are kept unless `--translate-all` is used. |
|
|
181
|
+
| `i18ntk --command=translate` / `i18ntk-translate` | Auto-translates locale JSON using configured provider behavior. | Missing, empty, untranslated-marker, source-copy, likely-English, or visibly corrupt target values by default. | Target locale JSON files and translation reports. Existing translated values are kept unless `--translate-all` is used. If unresolved values remain after retry, writes `i18ntk-reports/auto-translate/latest.json` for targeted follow-up. |
|
|
177
182
|
| `i18ntk --command=sizing` / `i18ntk-sizing` | Estimates translated string length expansion and layout risk. | Text length, expansion ratios, placeholder-bearing strings. | Sizing report. Does not edit locale files. |
|
|
178
183
|
| `i18ntk --command=summary` / `i18ntk-summary` | Shows project translation status. | Configured locales, reports, completeness status. | Console/report output only. |
|
|
179
184
|
| `i18ntk-fixer` | Fixes placeholder and missing-marker issues, and can audit English source files with `--check-placeholders`. | Placeholder corruption, missing translation markers, configured language files, `[LANG] ...` leftovers in English locales. | Locale JSON files when fixes are applied. Use dry-run options where available before bulk edits. |
|
|
@@ -573,7 +578,7 @@ See [docs/api/CONFIGURATION.md](./docs/api/CONFIGURATION.md) for the full config
|
|
|
573
578
|
|
|
574
579
|
## Public Package Contents
|
|
575
580
|
|
|
576
|
-
The public package intentionally ships runtime and CLI files only.
|
|
581
|
+
The public package intentionally ships runtime and CLI files only.
|
|
577
582
|
|
|
578
583
|
The package includes:
|
|
579
584
|
|