i18ntk 4.3.3 → 4.4.1

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 CHANGED
@@ -3,101 +3,154 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [4.3.3] - 2026-06-01
9
-
10
- ### Fixed
11
- - Usage extraction no longer reports ordinary method calls such as `get("next")`, `headers.get("etag")`, `set(...)`, or `setItem(...)` as missing translation keys.
12
- - Usage insights now resolve `tx(...)` wrapper calls and bounded dynamic `tx` template keys, reducing false unused-key reports for local wrappers.
13
- - 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.
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.
15
-
16
- ## [4.3.2] - 2026-05-31
17
-
18
- ### Changed
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.
21
-
22
- ## [4.3.1] - 2026-05-31
23
-
24
- ### Fixed
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [4.4.1] - 2026-06-02
9
+
10
+ ### Security
11
+ - **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.
12
+ - **HIGH**: Backup `handleCreate`, `handleRestore` now use `SecurityUtils.safeWriteFileSync`, `safeReadFileSync`, `safeMkdirSync` instead of raw `fs.promises`/`fs` calls.
13
+ - **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.
14
+ - **HIGH**: `config-helper` dual-path resolution (when both `--source-dir` and `--i18n-dir` are explicit) now wraps each resolved path in `SecurityUtils.validatePath()`.
15
+ - **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.
16
+ - **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.
17
+ - **MEDIUM**: `sanitizeInput` default character whitelist tightened — removed `\\`, `{`, `}` characters that could enable path traversal or template injection.
18
+ - **MEDIUM**: VSCode Workbench `workspaceScanner.ts` now validates auto-translate report paths with `normalizeWithinRoot()` and rejects JSON content > 50 MB.
19
+ - **MEDIUM**: VSCode Workbench `localeFileService.ts` now validates `addKey()` write paths via `isPathWithinRoot()` and rejects locale files > 10 MB before parsing.
20
+ - **LOW**: i18ntk Lens `scanner.ts` now rejects custom wrapper names > 100 characters to prevent ReDoS via malicious VSCode config values.
21
+
22
+ ### Added
23
+ - `SecurityUtils.MAX_JSON_SIZE`, `SecurityUtils.MAX_JSON_DEPTH`, `SecurityUtils.MAX_FILENAME_LENGTH` constants for configurable safety limits.
24
+
25
+ ## [4.4.0] - 2026-06-02
26
+
27
+ ### Added
28
+ - 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.
29
+ - Locale JSON import detection: `import en from '../../locales/en/foo.json'` is detected and property accesses are tracked as key usages.
30
+ - Confidence-split unused key reports: confirmed (≥80%), likely (40-80%), possibly used (<40%).
31
+ - `--strict-unused` flag: only reports high-confidence confirmed unused keys.
32
+ - `--json` flag: outputs structured JSON report for automation and CI/CD.
33
+ - `--prune` / `--prune-keep` flags: removes stale report files, keeping N most recent.
34
+ - Mojibake detection: replacement-character artifacts like `Abwicklungspr?fung` and `L?ser` detected during translation analysis.
35
+ - Client-boundary warnings: flags `"use client"` files that import locale JSON, which bypasses i18ntk runtime and increases bundle size.
36
+ - Copy-formatter detection: identifies local `const tx = ...` functions that do not call known translation runtimes.
37
+ - Wrapper configuration: `.i18ntk-config` now supports `usage.translationFunctions`, `usage.serverWrappers`, and `usage.copyFormatters`.
38
+ - Next.js App Router detection: identifies `"use server"` / `"use client"` directives and reports component type.
39
+ - VSCode `i18ntk.clearDiagnostics` command. Stale diagnostics now cleared at scan start.
40
+ - VSCode new diagnostic codes: `i18ntk.clientBoundary` (warning), `i18ntk.copyFormatter` (warning).
41
+ - Lens scanner: `detectSuspectedCopyFormatters()` and `findClientBoundaryLocaleImports()` exported.
42
+ - 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.
43
+ - 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.
44
+ - Bounded dynamic expansion suggestions in usage report with explicit-map recommendation pattern.
45
+ - 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.
46
+ - Object-method translation calls: `input.tx("key")`, `helper.tx("key")`, and `.tx(\`key.${var}\`)` are now recognized as translation calls alongside standalone `tx()`.
47
+ - 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.
48
+
49
+ ### Fixed
50
+ - `--source-dir` and `--i18n-dir` no longer forced to the same value when both are explicitly passed via CLI.
51
+ - Path display (`displayPaths`) now reflects CLI overrides instead of only config file values.
52
+ - Dead-key detection `_matchesDynamicPattern` replaced with `_matchesDynamicPrefix` using actual resolved data.
53
+ - Locale JSON import detection properly deduplicates namespace prefix (e.g., `leaderboard.error` not `leaderboard.leaderboard.error`).
54
+ - 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.
55
+ - Object-method `tx()` calls and local wrapper functions are now included in usage analysis, preventing Lens false positives on keys used through these patterns.
56
+
57
+ ### Changed
58
+ - VSCode workbench bumped to 1.1.0, lens extension to 1.1.0.
59
+ - Major changes list in package.json and package.public.json updated for 4.4.0.
60
+
61
+ ## [4.3.3] - 2026-06-01
62
+
63
+ ### Fixed
64
+ - Usage extraction no longer reports ordinary method calls such as `get("next")`, `headers.get("etag")`, `set(...)`, or `setItem(...)` as missing translation keys.
65
+ - Usage insights now resolve `tx(...)` wrapper calls and bounded dynamic `tx` template keys, reducing false unused-key reports for local wrappers.
66
+ - 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.
67
+ - 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.
68
+
69
+ ## [4.3.2] - 2026-05-31
70
+
71
+ ### Changed
72
+ - Documentation, README badges, and migration guidance now reference the current 4.3.2 release.
73
+ - Release metadata now marks 4.3.0 for npm deprecation because its npm tarball is unavailable.
74
+
75
+ ## [4.3.1] - 2026-05-31
76
+
77
+ ### Fixed
25
78
  - 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
79
  - 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
80
  - Removed inconsistent `.js` extension suffixes from require paths in `main/i18ntk-js.js`.
28
81
 
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
82
+ ## [4.3.0] - 2026-05-31
83
+
84
+ ### Fixed
85
+ - 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.
86
+ - Auto Translate now treats bracketed target-language placeholders case-insensitively, so `[zh] Email` and `[TR] Password` are both retried for the matching target language.
87
+ - 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.
88
+ - Auto Translate no longer fails a run when a provider legitimately returns a short all-caps acronym or code unchanged, such as `XP`.
89
+ - 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.
90
+ - The management command router no longer prints a generic operation-success message when a command returns `{ success: false }`.
91
+
92
+ ## [4.2.1] - 2026-05-31
93
+
94
+ ### Changed
95
+ - 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.
96
+ - 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.
97
+ - 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.
98
+
99
+ ### Fixed
100
+ - 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.
101
+ - 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.
102
+ - Manager sizing now treats a failed sizing analysis as a command failure instead of printing a generic operation success.
103
+ - Validation summary reports now include warning and error details, including content-risk warning payloads, instead of only totals.
104
+
105
+ ## [4.2.0] - 2026-05-30
106
+
107
+ ### Security
108
+ - Shared path validation no longer permits artifact-like filenames such as `.lock` or `.temp-config.json` to bypass base-directory containment.
109
+ - Shared path validation now rejects Windows cross-drive escape cases where `path.relative()` returns an absolute path.
110
+ - Custom `I18NTK_INTERNAL_PATH_PREFIXES` entries can no longer mark arbitrary outside directories as internal roots.
111
+ - Backup restore now rejects backup entry names containing path separators, absolute paths, traversal, or non-JSON names before writing restored files.
112
+ - Runtime locale loading now validates language identifiers before resolving single-file or directory locale paths, blocking `../` language names from reading JSON outside `baseDir`.
113
+ - Auto Translate provider URL validation now blocks IPv4-mapped IPv6 loopback/private hosts.
114
+
115
+ ### Changed
116
+ - Main runtime now includes production-safe features from the enhanced runtime surface: per-call language overrides, synchronous `translateBatch()`, and `clearCache()` / `getCacheInfo()` helpers.
117
+ - `i18ntk/runtime/enhanced` remains available as a legacy public subpath for compatibility, while new production integrations should prefer the lightweight `i18ntk/runtime` API.
118
+ - Usage analysis now indexes known translation keys back to source files, including direct i18n calls and literal key references that were previously missed.
119
+ - 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.
120
+ - Usage reports now list unresolved dynamic key expressions separately instead of treating broad wildcard prefixes as proof that every matching key is used.
121
+ - Usage reports now include namespace/file naming recommendations such as preferring `shop.*` keys and `shop.json` for `/shop` page or route files.
122
+ - 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.
123
+ - Translation analysis and init reports now default to Markdown for readable output, with `reports.format` supporting `markdown`, `json`, or `text` through settings and config.
124
+ - Init default target languages now include English (`en`) before `de`, `es`, `fr`, and `ru` when the UI is running in another language.
125
+ - Confirmation prompts now accept localized native yes/no input for supported UI languages while retaining English fallback tokens.
126
+ - Auto Translate has moved out of beta in menus and documentation, and its settings are exposed with localized labels.
127
+ - 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.
128
+ - Auto Translate now treats visibly corrupt target strings such as `?????`, Unicode replacement characters, and common mojibake as needing retranslation from the source language.
129
+ - 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.
130
+ - Auto Translate progress output now separates string translation from placeholder-safe text-segment translation and shows the active key path during progress updates.
131
+ - Placeholder detection now covers ICU plural/select blocks, i18next nested `$t(...)` references, and wider named printf formats such as `%(total).2f`.
132
+ - Manager menu output is now grouped with clearer spacing and aligned option numbers.
133
+ - Documentation now consolidates migration guidance around `4.2.0` and removes stale old per-version migration guides from the working docs tree.
134
+ - Removed stale duplicate development artifacts `main/manage/index-fixed.js` and `utils/security-fixed.js` to reduce audit drift and prevent accidental reuse.
135
+ - Updated public, root, and development package metadata for the 4.2.0 release line.
136
+
137
+ ### Fixed
138
+ - 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.
139
+ - 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.
140
+ - 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.
141
+ - Init backup prompts, completion summaries, report prompts, and report status text now use bundled UI locale keys instead of hard-coded English.
142
+ - Bundled UI locales were regenerated from `ui-locales/en.json` for newly added, source-copy, and corrupt target strings.
143
+ - JSON report output is now pretty-printed object JSON instead of a single JSON string containing escaped newlines.
144
+ - The managed Auto Translate command no longer forces UI translations back to English after the user has selected another UI language.
145
+ - Manager validation output no longer prints duplicate source/i18n/output directory blocks before the validator summary.
146
+ - `i18ntk-setup --help` now exits after printing help instead of running setup and writing project files.
147
+ - `npm run languages:list` and `npm run languages:status` now produce non-interactive output instead of opening the settings menu.
148
+ - `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.
149
+ - Removed a stale bundled `locales/es/navigation.json` fixture that made `i18ntk-doctor` report a dangling namespace after setup/init tests.
150
+
151
+ ## [4.1.0] - 2026-05-21
152
+
153
+ ### Fixed
101
154
  - Runtime: stale manifest entries (deleted files after manifest construction) no longer cause unhandled exceptions; loadedFiles set before load with try/catch guard.
102
155
  - Runtime: `refresh()` now correctly clears the key manifest for the refreshed language, preventing stale file references.
103
156
  - Runtime: null `baseDir` guard prevents cascading `validatePath(null)` errors in `loadKeyManifestFromDir`.
@@ -135,20 +188,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
135
188
  - Public package metadata updated.
136
189
 
137
190
  ### Security
138
- - Watch module: debounce timers properly cleaned up on stop and callback subscriptions corrected for object-format and unlink handlers.
191
+ - Watch module: debounce timers properly cleaned up on stop and callback subscriptions corrected for object-format and unlink handlers.
139
192
  - Runtime: loadedFiles lock-before-load pattern prevents duplicate I/O and stale manifest crash.
140
193
  - Backup: circular parent reference detection; `--incremental=false` string truthy bypass closed.
141
194
  - Sizing: adminAuth variable reference corrected; require()-time `process.exit()` guarded.
142
195
  - Scanner: vanilla framework key prevents `undefined` return; stopword-less validRatio enforced.
143
196
  - Usage: O(n+m) comment scanning prevents DoS via large codebase with many dead keys; `toBool()` prevents flag injection.
144
197
  - 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.
198
+ - Protection: Unicode-aware punctuation boundaries for CJK/Cyrillic/Arabic; standalone boundaries include the expanded punctuation set.
146
199
 
147
200
  ## [4.0.0] - 2026-05-21
148
201
 
149
202
  ### Added
150
203
  - **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()`.
204
+ - **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
205
  - **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
206
  - **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
207
  - **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 +212,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
159
212
  ### Fixed
160
213
  - `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
214
 
162
- ### Changed
215
+ ### Changed
163
216
  - `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
217
  - **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
218
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # i18ntk v4.3.3
1
+ # i18ntk v4.4.1
2
2
 
3
- A i18n toolkit - A zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, translation completion, automatic JSON locale translation, reporting, and runtime translation loading.
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
  ![i18ntk Logo](https://raw.githubusercontent.com/vladnoskv/i18ntk/main/docs/screenshots/i18ntk-logo-public.PNG)
6
6
 
@@ -9,19 +9,11 @@ A i18n toolkit - A zero-dependency internationalization toolkit for setup, scann
9
9
  [![node](https://img.shields.io/badge/node-%3E%3D16-339933)](https://nodejs.org)
10
10
  [![dependencies](https://img.shields.io/badge/dependencies-0-success)](https://www.npmjs.com/package/i18ntk)
11
11
  [![license](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
12
- [![socket](https://socket.dev/api/badge/npm/package/i18ntk/4.3.3)](https://socket.dev/npm/package/i18ntk/overview/4.3.3)
13
- ## VS Code Extensions
12
+ [![socket](https://socket.dev/api/badge/npm/package/i18ntk/4.4.1)](https://socket.dev/npm/package/i18ntk/overview/4.4.1)
14
13
 
15
14
  [![i18ntk Workbench](https://img.shields.io/badge/VS_Code-i18ntk_Workbench-007ACC?logo=visualstudiocode&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=VladNoskov.i18ntk-workbench)
16
15
  [![i18ntk Lens](https://img.shields.io/badge/VS_Code-i18ntk_Lens-007ACC?logo=visualstudiocode&logoColor=white)](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,58 +27,64 @@ npm install --save-dev i18ntk
35
27
  npx i18ntk --help
36
28
  ```
37
29
 
38
- Requirements:
30
+ ## i18ntk Summary
39
31
 
40
- - Node.js `>=16.0.0`
41
- - npm `>=8.0.0`
42
- - No runtime dependencies
32
+ **What it does**
43
33
 
44
- ## What's New in 4.3.3
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.
45
39
 
46
- - **USAGE FIX**: Usage extraction no longer treats ordinary method calls such as `get("next")`, `headers.get("etag")`, `set(...)`, or `setItem(...)` as translation calls.
47
- - **USAGE FIX**: Local `tx(...)` wrappers and bounded dynamic `tx` template usages are resolved so real keys are less likely to appear unused.
48
- - **KEY STYLE**: Hybrid dot-path plus snake_case segment keys are valid, for example `namespace.section.snake_case_leaf`; malformed separators and uppercase segments are still reported.
49
- - **SAFETY**: Unused-key reports are advisory. Do not bulk-delete keys from an unused report without manual verification or a precise usage scan.
40
+ **What it does not do**
50
41
 
51
- ## What's New in 4.3.2
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.
52
45
 
53
- - **DOCS**: README, API docs, and migration guidance now reflect the current 4.3.2 package version.
54
- - **RELEASE**: 4.3.0 is marked for npm deprecation because its npm tarball is unavailable; install 4.3.1 or newer.
46
+ **Why not i18next?**
55
47
 
56
- ## What's New in 4.3.1
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.
57
49
 
58
- - **FIX**: Published tarball now includes `utils/english-placeholder-checker.js`, resolving `MODULE_NOT_FOUND` at startup for `i18ntk-fixer --check-placeholders` and manager option 7.
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`.
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 |
61
58
 
62
- ## What's New in 4.3.0
59
+ ## What's New in 4.4.1
63
60
 
64
- - **AUTO TRANSLATE**: Existing target values like `[AR] What We Offer`, `[AR] Email`, `[zh] Email`, and `[TR] Password` are now treated as untranslated placeholders for the matching target language and are translated from the source text.
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.
61
+ - **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.
62
+ - **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.
63
+ - **CONFIDENCE-SPLIT REPORTS**: Unused keys are now reported by confidence tier confirmed (≥80%), likely (40-80%), possibly used (<40%) instead of a flat list.
64
+ - **NEW CLI FLAGS**: `--strict-unused` (only high-confidence keys), `--json` (structured JSON output for CI), `--prune` / `--prune-keep` (stale report cleanup).
65
+ - **MOJIBAKE DETECTION**: Replacement-character artifacts like `Abwicklungspr?fung` and `L?ser` are detected during translation analysis.
66
+ - **CLIENT-BOUNDARY WARNINGS**: `"use client"` files importing locale JSON are flagged this bypasses the runtime and increases bundle size.
67
+ - **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.
68
+ - **CONFIG FIX**: `--source-dir` and `--i18n-dir` are no longer forced equal when both are explicitly passed via CLI.
69
+ - **Next.js DETECTION**: App Router files with `"use server"` / `"use client"` directives are now detected and reported by component type.
70
+ - **VSCode DIAGNOSTICS**: New `i18ntk.clearDiagnostics` command. Stale diagnostics are now cleared at scan start. New diagnostic codes: `i18ntk.clientBoundary`, `i18ntk.copyFormatter`.
71
+ - **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.
72
+ - **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.
73
+ - **WRAPPER CONFIG**: `.i18ntk-config` now supports `usage.translationFunctions`, `usage.serverWrappers`, and `usage.copyFormatters` for fine-grained control.
74
+ - **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.
75
+ - **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.
73
76
 
74
- ## What's New in 4.1.0
77
+ - **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.
75
78
 
76
- - **FIX**: Critical and high-impact bugs resolved across the v4.0.0 feature set — runtime staleness crashes, backup hash-chain verification, sizing adminAuth crash, scanner `--source-language` propagation, watch callback subscriptions, dead key detection performance, validator key style enforcement, and protection Unicode boundary handling. See [CHANGELOG.md](./CHANGELOG.md) for complete details.
79
+ See [CHANGELOG.md](./CHANGELOG.md) for more release details.
77
80
 
78
- ## What's New in 4.0.0
81
+ ## Security hardening in 4.4.1
79
82
 
80
- - **SIZING**: `--predict-expansion` flag computes per-key expansion ratios across languages with Safe/Warning/Critical risk tiers for UI layout planning.
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.
83
+ - **PATH TRAVERSAL HARDENED**: Backup, complete, and config-helper commands now validate all user-supplied paths through `SecurityUtils.validatePath()`, blocking writes outside project boundaries.
84
+ - **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.
85
+ - **INPUT SANITIZATION TIGHTENED**: `sanitizeInput` default whitelist no longer allows backslashes or curly braces that could enable path traversal or template injection.
88
86
 
89
- See [CHANGELOG.md](./CHANGELOG.md) for more release details.
87
+ - **LIBRETRANSLATE URL GATED**: Custom LibreTranslate host now requires `I18NTK_ALLOW_CUSTOM_LIBRETRANSLATE_HOST=1` env flag (parity with DeepL).
90
88
 
91
89
  ## Quick Start
92
90
 
@@ -173,7 +171,7 @@ Note: manager route `i18ntk --command=backup` is disabled in current builds. Use
173
171
  | `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
172
  | `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
173
  | `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. |
174
+ | `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
175
  | `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
176
  | `i18ntk --command=summary` / `i18ntk-summary` | Shows project translation status. | Configured locales, reports, completeness status. | Console/report output only. |
179
177
  | `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 +571,7 @@ See [docs/api/CONFIGURATION.md](./docs/api/CONFIGURATION.md) for the full config
573
571
 
574
572
  ## Public Package Contents
575
573
 
576
- The public package intentionally ships runtime and CLI files only. The publish staging script excludes development-only content such as tests, scripts, docs, release staging folders, local config files, and generated protection files.
574
+ The public package intentionally ships runtime and CLI files only.
577
575
 
578
576
  The package includes:
579
577