i18n check script fails to detect missing translation keys and has critical logic flaws #15729

Closed
opened 2026-02-21 19:23:04 -05:00 by yindo · 0 comments
Owner

Originally created by @lyzno1 on GitHub (Jul 28, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

main

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Navigate to the web directory: cd web
  2. Try to run the i18n consistency check: pnpm check-i18n
  3. Observe the error: Cannot find module '/path/to/web/i18n/check-i18n.js'
  4. Check package.json line 32: script points to ./i18n/check-i18n.js but file is at ./i18n-config/check-i18n.js
  5. Fix the path manually and run again
  6. Notice the script reports "no missing keys" across all languages
  7. Manually verify a known missing key: grep -n "clearAllConfirm" i18n/*/app-annotation.ts
    • Result shows only 3 languages have this key, but script doesn't detect the missing ones
  8. Check Traditional Chinese specifically: grep "clearAllConfirm" i18n/zh-Hant/app-annotation.ts (returns nothing)
  9. Verify English has the key: grep "clearAllConfirm" i18n/en-US/app-annotation.ts (returns the key)

✔️ Expected Behavior

  • The pnpm check-i18n command should execute successfully without path errors
  • The script should accurately detect missing translation keys across all locales
  • It should report that zh-Hant (and other locales) are missing appAnnotation.table.header.clearAllConfirm
  • Should provide detailed output showing specific missing keys for each locale
  • Should serve as a reliable tool for maintaining i18n consistency and preventing translation gaps
  • Should help developers identify incomplete translations before they reach production

Actual Behavior

Primary Issue - Script Path Mismatch:

  • Command fails with MODULE_NOT_FOUND error due to incorrect path in package.json
  • Script references ./i18n/check-i18n.js but actual file is at ./i18n-config/check-i18n.js

Critical Logic Flaws (Even After Path Fix):

The script has fundamental bugs that cause false negative results:

1. Array Overwrite Bug:

files.forEach((file) => {
  // Process each translation file
  allKeys = [...keys, ...nestedKeys].map(key => `${camelCaseFileName}.${key}`)
  // ❌ OVERWRITES previous files' keys instead of accumulating
})

2. Incorrect Object Extraction:

const translationObj = eval(transpile(content))
// ❌ Returns exports object, not the actual translation object

3. Wrong Path Resolution:

const folderPath = path.join(__dirname, language)
// ❌ Looks in i18n-config/{language} instead of ../i18n/{language}

Real-World Impact:

  • Script reports "0 missing keys" when zh-Hant is actually missing clearAllConfirm and many others
  • Developers get false confidence that translations are complete
  • Missing translations slip into production (like the Traditional Chinese "Delete all annotations?" dialog showing in English)
  • Manual verification required, defeating the purpose of automated i18n checking
  • Translation inconsistencies accumulate over time without detection
Originally created by @lyzno1 on GitHub (Jul 28, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version main ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. Navigate to the web directory: `cd web` 2. Try to run the i18n consistency check: `pnpm check-i18n` 3. Observe the error: `Cannot find module '/path/to/web/i18n/check-i18n.js'` 4. Check `package.json` line 32: script points to `./i18n/check-i18n.js` but file is at `./i18n-config/check-i18n.js` 5. Fix the path manually and run again 6. Notice the script reports "no missing keys" across all languages 7. Manually verify a known missing key: `grep -n "clearAllConfirm" i18n/*/app-annotation.ts` - Result shows only 3 languages have this key, but script doesn't detect the missing ones 8. Check Traditional Chinese specifically: `grep "clearAllConfirm" i18n/zh-Hant/app-annotation.ts` (returns nothing) 9. Verify English has the key: `grep "clearAllConfirm" i18n/en-US/app-annotation.ts` (returns the key) ### ✔️ Expected Behavior - The `pnpm check-i18n` command should execute successfully without path errors - The script should accurately detect missing translation keys across all locales - It should report that `zh-Hant` (and other locales) are missing `appAnnotation.table.header.clearAllConfirm` - Should provide detailed output showing specific missing keys for each locale - Should serve as a reliable tool for maintaining i18n consistency and preventing translation gaps - Should help developers identify incomplete translations before they reach production ### ❌ Actual Behavior ### Primary Issue - Script Path Mismatch: - Command fails with `MODULE_NOT_FOUND` error due to incorrect path in `package.json` - Script references `./i18n/check-i18n.js` but actual file is at `./i18n-config/check-i18n.js` ### Critical Logic Flaws (Even After Path Fix): The script has fundamental bugs that cause **false negative results**: #### 1. Array Overwrite Bug: ```javascript files.forEach((file) => { // Process each translation file allKeys = [...keys, ...nestedKeys].map(key => `${camelCaseFileName}.${key}`) // ❌ OVERWRITES previous files' keys instead of accumulating }) ``` #### 2. Incorrect Object Extraction: ```javascript const translationObj = eval(transpile(content)) // ❌ Returns exports object, not the actual translation object ``` #### 3. Wrong Path Resolution: ```javascript const folderPath = path.join(__dirname, language) // ❌ Looks in i18n-config/{language} instead of ../i18n/{language} ``` ### Real-World Impact: - Script reports "0 missing keys" when `zh-Hant` is actually missing `clearAllConfirm` and many others - Developers get false confidence that translations are complete - Missing translations slip into production (like the Traditional Chinese "Delete all annotations?" dialog showing in English) - Manual verification required, defeating the purpose of automated i18n checking - Translation inconsistencies accumulate over time without detection
yindo added the 🐞 bug label 2026-02-21 19:23:04 -05:00
yindo closed this issue 2026-02-21 19:23:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15729