[PR #23069] fix(scripts): resolve i18n check script path and logic issues #30145

Closed
opened 2026-02-21 20:46:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/23069

State: closed
Merged: Yes


Summary

Fixes #23068

This PR resolves critical logic flaws in the i18n consistency check script that were causing false negative results. The script was reporting "no missing keys" when translation keys were actually missing across multiple locales.

Problem

  • The pnpm check-i18n command failed due to incorrect script path in package.json
  • Even after path correction, the script had fundamental logic bugs that prevented accurate detection of missing translation keys
  • Developers received false confidence about translation completeness, leading to incomplete localizations in production

Solution

  • Fix package.json script path: ./i18n/check-i18n.js -> ./i18n-config/check-i18n.js
  • Fix function name typo: getKeysFromLanuage -> getKeysFromLanguage
  • Fix folder path resolution: use path.resolve(__dirname, '../i18n', language)
  • Fix array overwrite bug: accumulate keys with allKeys.push() instead of assignment
  • Fix translation object extraction: properly handle module.exports from transpiled code
  • Add file filtering: only process .ts and .js files
  • Add error handling: catch and report file processing errors
  • Add null check: prevent iterating over null objects

This resolves the script reporting false negatives (0 missing keys) when translation keys were actually missing. The script now accurately detects missing translations across all locales.

Impact

  • pnpm check-i18n command now works reliably
  • Accurate detection of missing translation keys across all 20 supported locales
  • Detailed reporting of specific missing keys per language
  • Improved i18n quality assurance for the development workflow

Screenshots

Before After
Cannot find module '/path/to/web/i18n/check-i18n.js' error when running pnpm check-i18n Script executes successfully and provides detailed missing key reports
Script reports "0 missing keys" for all languages (false negative) Script accurately detects and reports hundreds of actually missing translation keys

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/23069 **State:** closed **Merged:** Yes --- ## Summary Fixes #23068 This PR resolves critical logic flaws in the i18n consistency check script that were causing false negative results. The script was reporting "no missing keys" when translation keys were actually missing across multiple locales. ### Problem - The `pnpm check-i18n` command failed due to incorrect script path in package.json - Even after path correction, the script had fundamental logic bugs that prevented accurate detection of missing translation keys - Developers received false confidence about translation completeness, leading to incomplete localizations in production ### Solution - Fix package.json script path: `./i18n/check-i18n.js` -> `./i18n-config/check-i18n.js` - Fix function name typo: `getKeysFromLanuage` -> `getKeysFromLanguage` - Fix folder path resolution: use `path.resolve(__dirname, '../i18n', language)` - Fix array overwrite bug: accumulate keys with `allKeys.push()` instead of assignment - Fix translation object extraction: properly handle `module.exports` from transpiled code - Add file filtering: only process `.ts` and `.js` files - Add error handling: catch and report file processing errors - Add null check: prevent iterating over null objects This resolves the script reporting false negatives (0 missing keys) when translation keys were actually missing. The script now accurately detects missing translations across all locales. ### Impact - ✅ `pnpm check-i18n` command now works reliably - ✅ Accurate detection of missing translation keys across all 20 supported locales - ✅ Detailed reporting of specific missing keys per language - ✅ Improved i18n quality assurance for the development workflow ## Screenshots | Before | After | |--------|-------| | `Cannot find module '/path/to/web/i18n/check-i18n.js'` error when running `pnpm check-i18n` | Script executes successfully and provides detailed missing key reports | | Script reports "0 missing keys" for all languages (false negative) | Script accurately detects and reports hundreds of actually missing translation keys | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:46:56 -05:00
yindo closed this issue 2026-02-21 20:46:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30145