dify
dify copied to clipboard
Language internationalization switching exception
Self Checks
- [X] This is only for bug report, if you would like to ask a quesion, 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] Pleas do not modify this template :) and fill in all the required fields.
Dify version
The latest front-end code, as of commit 487ce7c82a3803b50
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
Switch language after entering the system
✔️ Expected Behavior
The value of lang on HTML should be the same as the current language value
https://github.com/langgenius/dify/assets/33956589/4248b412-2a9e-4110-924f-12bd8d97c9aa
❌ Actual Behavior
No matter how I switch, it will change to the language option I set before.
It sounds like the issue with the lang
attribute not updating correctly when switching languages is due to the attribute being set initially by server-side logic, which doesn't rerun on client-side navigation changes. To fix this, you'll need to implement a client-side solution that dynamically updates the lang
attribute of the <html>
tag whenever the language is switched by the user.
This involves setting up a mechanism, possibly using state or context, to monitor changes in the language selection and then applying those changes to the lang
attribute directly on the client side. This way, the lang
attribute will accurately reflect the current language as users navigate your application and switch languages.
For implementation, you might want to look into the web/app/layout.tsx
file for the relevant code sections where this logic could be integrated.
Details
Sources
- web/app/layout.tsx
- web/i18n/server.ts
- web/app/activate/activateForm.tsx
- web/i18n/language.ts
- web/i18n/README.md
- web/i18n/ja-JP/common.ts
- web/i18n/fr-FR/common.ts
- .github/ISSUE_TEMPLATE/translation_issue.yml
- web/i18n/index.ts
- web/app/components/i18n.tsx
About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
For me it is working fine, and the lang in HTML is changing. Isn't that an issue with Google translate? Did you tried without it or another browser?
@patryk20120 Oh, thanks for the reminder, I found the reason, it’s precisely because of Google Translate