[PR #18509] feat(embedded-chatbot): support overriding locale via URL params #28931

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

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

State: closed
Merged: Yes


Summary

This fixes #18503

Description

This PR enables the Dify embedded chatbot to override its default language using a URL parameter or system variable. This allows the chatbot to be displayed in different languages depending on the embedding context, without requiring server-side configuration changes.

Changes Made

  • File changed: web/app/components/base/chat/embedded-chatbot/hooks.tsx
    • Added logic in the useEmbeddedChatbot hook to:
      • Check for a locale parameter in the URL and use it to set the chatbot language.
      • Check for a locale value in the decoded system variables if the URL parameter is not present.
      • Fall back to the app’s default language if neither override is provided.
    • The language is set using the changeLanguage function from the i18n configuration.

Testing Done

  • Embedded the chatbot with ?locale=es-ES in the URL and verified the UI loaded in Spanish.
  • Tested with a system variable override (sys.locale) and confirmed the language switched accordingly.
  • Verified that, in the absence of overrides, the chatbot uses the default language from the app configuration.
  • Confirmed that other chatbot features and conversation flows remain unaffected by the locale change.

Checklist

Important

Please review the checklist below before submitting your pull request.

  • 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/18509 **State:** closed **Merged:** Yes --- # Summary This fixes #18503 ## Description This PR enables the Dify embedded chatbot to override its default language using a URL parameter or system variable. This allows the chatbot to be displayed in different languages depending on the embedding context, without requiring server-side configuration changes. ## Changes Made - **File changed:** `web/app/components/base/chat/embedded-chatbot/hooks.tsx` - Added logic in the `useEmbeddedChatbot` hook to: - Check for a `locale` parameter in the URL and use it to set the chatbot language. - Check for a `locale` value in the decoded system variables if the URL parameter is not present. - Fall back to the app’s default language if neither override is provided. - The language is set using the `changeLanguage` function from the i18n configuration. ## Testing Done - Embedded the chatbot with `?locale=es-ES` in the URL and verified the UI loaded in Spanish. - Tested with a system variable override (`sys.locale`) and confirmed the language switched accordingly. - Verified that, in the absence of overrides, the chatbot uses the default language from the app configuration. - Confirmed that other chatbot features and conversation flows remain unaffected by the locale change. # Checklist > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] 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:44:24 -05:00
yindo closed this issue 2026-02-21 20:44:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#28931