ai-localize-validators 2.0.4 → 2.0.5

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
@@ -1,5 +1,24 @@
1
1
  # ai-localize-validators
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - **Bug fix — `validate` always reported "valid"**: `MissingKeyValidator` now correctly
8
+ detects un-translated keys when the extractor has seeded target language files with the
9
+ English source value (the `localeStructure` default behaviour introduced in 2.0.3).
10
+ Previously the check `targetValue === ""` never fired because values were non-empty strings;
11
+ the validator now adds a third condition — `targetValue === sourceValue` — so a key that
12
+ still holds its English placeholder is flagged as "Missing translation (value equals source)".
13
+ (`packages/validators/src/missing-key-validator.ts`)
14
+
15
+ ## 2.0.4
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - ai-localize-shared@2.0.4
21
+
3
22
  ## 2.0.3
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -66,9 +66,18 @@ var MissingKeyValidator = class {
66
66
  const targetPath = path.join(this.localesDir, lang, nsFile);
67
67
  const targetEntries = (0, import_ai_localize_shared.readJsonSafe)(targetPath) || {};
68
68
  for (const key of Object.keys(defaultEntries)) {
69
- if (!(key in targetEntries) || targetEntries[key] === "") {
69
+ const sourceValue = defaultEntries[key];
70
+ const targetValue = targetEntries[key];
71
+ const isMissing = !(key in targetEntries) || targetValue === "" || targetValue !== void 0 && targetValue === sourceValue;
72
+ if (isMissing) {
70
73
  const fullKey = `${namespace}.${key}`;
71
- errors.push({ type: "missing-key", key: fullKey, language: lang, message: `Missing key "${fullKey}" in "${lang}"`, filePath: targetPath });
74
+ errors.push({
75
+ type: "missing-key",
76
+ key: fullKey,
77
+ language: lang,
78
+ message: `Missing translation for "${fullKey}" in "${lang}" (value equals source)`,
79
+ filePath: targetPath
80
+ });
72
81
  if (!missingByLanguage[lang]) missingByLanguage[lang] = [];
73
82
  missingByLanguage[lang].push(fullKey);
74
83
  }
package/dist/index.mjs CHANGED
@@ -26,9 +26,18 @@ var MissingKeyValidator = class {
26
26
  const targetPath = path.join(this.localesDir, lang, nsFile);
27
27
  const targetEntries = readJsonSafe(targetPath) || {};
28
28
  for (const key of Object.keys(defaultEntries)) {
29
- if (!(key in targetEntries) || targetEntries[key] === "") {
29
+ const sourceValue = defaultEntries[key];
30
+ const targetValue = targetEntries[key];
31
+ const isMissing = !(key in targetEntries) || targetValue === "" || targetValue !== void 0 && targetValue === sourceValue;
32
+ if (isMissing) {
30
33
  const fullKey = `${namespace}.${key}`;
31
- errors.push({ type: "missing-key", key: fullKey, language: lang, message: `Missing key "${fullKey}" in "${lang}"`, filePath: targetPath });
34
+ errors.push({
35
+ type: "missing-key",
36
+ key: fullKey,
37
+ language: lang,
38
+ message: `Missing translation for "${fullKey}" in "${lang}" (value equals source)`,
39
+ filePath: targetPath
40
+ });
32
41
  if (!missingByLanguage[lang]) missingByLanguage[lang] = [];
33
42
  missingByLanguage[lang].push(fullKey);
34
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-localize-validators",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Locale file validation engine — missing, duplicate, placeholder and unused key validators",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "node": ">=18.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "ai-localize-shared": "2.0.4"
36
+ "ai-localize-shared": "2.0.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "tsup": "^8.0.1",