dify icon indicating copy to clipboard operation
dify copied to clipboard

web script i18n/check-i18n.js can not run any more

Open kindy opened this issue 10 months ago • 3 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

sha: ea1d45942

Cloud or Self Hosted

Self Hosted (Source), Cloud

Steps to reproduce

  • use web UI
  • see some text is missing (billing.plansCommon.documentProcessingPriorityTip)
  • clone code and check source, seems en-US missing some key
  • find check-i18n.js, try to run it
  • fail
cd web
node i18n/check-i18n.js

✔️ Expected Behavior

check missing keys

❌ Actual Behavior

throw error:

~dify/web/i18n/check-i18n.js:39
        const keys = Object.keys(translation);
                            ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at ~dify/web/i18n/check-i18n.js:39:29
    at Array.forEach (<anonymous>)
    at ~dify/web/i18n/check-i18n.js:23:13
    at FSReqCallback.oncomplete (node:fs:188:23)

Node.js v23.2.0

kindy avatar Mar 27 '25 12:03 kindy

Hello @kindy! I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let's work together to resolve the issue you're facing.

The error you're encountering with the i18n/check-i18n.js script is likely due to the script attempting to evaluate a file content that does not result in a valid object. Specifically, it seems that one of the translation files, such as web/i18n/en-US/register.ts, might be exporting an empty object or is missing the expected keys and values [1].

To resolve this issue, you should:

  1. Check the Translation Files: Ensure that all translation files in the en-US directory, including register.ts, are populated with the necessary keys and values. These files should contain key-value pairs where the key is a string identifier used in the application, and the value is the English translation of that string [2].

  2. Add Error Handling: Consider adding error handling around the eval statement in the script to catch and log any issues with specific files. This can help identify which files are causing the problem.

By ensuring that the translation files are correctly populated and adding error handling, you should be able to run the script without encountering the "TypeError: Cannot convert undefined or null to object" error.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Mar 27 '25 12:03 dosubot[bot]

I'll open a PR to fix it.

  • [ ] make it works again
  • [x] check all languages, not only based-on en-US

cc @crazywoola

kindy avatar Mar 27 '25 12:03 kindy

Thanks, feel free to open a PR

crazywoola avatar Mar 27 '25 13:03 crazywoola