Skip to content

fix(widget): move hardcoded UI text to locale strings - #150

Merged
anurag629 merged 3 commits into
codercops:devfrom
anurag2787:fix/widget-locale-strings
Oct 17, 2026
Merged

anurag629 merged 3 commits into
codercops:devfrom
anurag2787:fix/widget-locale-strings

Conversation

@anurag2787

Copy link
Copy Markdown
Contributor

What does this change?

Moved hardcoded UI text and aria-labels to locale strings so they can be customized and translated. Also updated the bubble close button for better accessibility

Closes #61

How I tested this

  • Updated the existing tests and checked that they pass.
  • Verified that custom strings are applied correctly to button labels.

AI assistance

Used ChatGPT for assistance with wording and implementation

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • Docs updated if behavior or options changed

anurag2787 and others added 2 commits October 16, 2026 21:00
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@anurag2787

Copy link
Copy Markdown
Contributor Author

Hi @anurag629 could you please review and let me know if any changes required
Thanks!

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anurag2787. The labels part works: the FAB, the header close, the send button and the bubble dismiss all read from the locale now, the Cerrar test passes, and typecheck and all 257 tests pass.

One regression in the greeting though. When a visitor gives their name in the pre-chat form, the site's own welcomeMessage is dropped. With welcomeMessage: 'Welcome to Acme support.' and the name Alex, dev shows Hi Alex! Welcome to Acme support. and this branch shows Hi Alex! How can I help you today?. So any site with its own welcome text loses it as soon as someone fills in their name.

Can you make greetingWithName only the greeting part ('Hi {name}!') and put the welcome message after it like before, ${greeting} ${this.config.welcomeMessage ?? this.locale.welcomeMessage}? Then the English text is the same as today.

While you're on that line, pass a function to replace: .replace('{name}', () => userName). With a string, $& and the other $ patterns in the replacement get expanded, so a name typed as A$&B comes out as Hi A{name}B!.

Please also add a test with a custom welcomeMessage and a name (it should fail on this branch), and add the six new keys to the "Locale Strings" block in website/src/content/docs/widget/i18n.mdx, since the checklist says the docs are updated.

@anurag629 anurag629 mentioned this pull request Oct 16, 2026
8 tasks
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@anurag2787
anurag2787 requested a review from anurag629 October 17, 2026 05:44

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anurag2787, that covers everything. I merged it onto current dev and ran the build, typecheck and tests (261 pass). The custom welcome message test and the $& test both fail with the previous version of this branch, and Hi Alex! Welcome to Acme support. is back. Dropping the "Hi!" from the default welcome message is fine with me, since a named visitor got "Hi Alex! Hi! How can I help you today?" on dev. Merging.

@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 17, 2026
@anurag629
anurag629 merged commit 70fa9c3 into codercops:dev Oct 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move hardcoded English UI text and aria-labels into locale strings

2 participants