dify icon indicating copy to clipboard operation
dify copied to clipboard

Language internationalization switching exception

Open TinsFox opened this issue 9 months ago • 2 comments

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.

TinsFox avatar May 09 '24 08:05 TinsFox

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


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.

dosubot[bot] avatar May 09 '24 08:05 dosubot[bot]

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 avatar May 09 '24 11:05 patryk20120

@patryk20120 Oh, thanks for the reminder, I found the reason, it’s precisely because of Google Translate

TinsFox avatar May 09 '24 12:05 TinsFox