Repository navigation
fix(widget): move hardcoded UI text to locale strings - #150
Conversation
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
|
Hi @anurag629 could you please review and let me know if any changes required |
anurag629
left a comment
There was a problem hiding this comment.
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.
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
anurag629
left a comment
There was a problem hiding this comment.
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.
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
AI assistance
Used ChatGPT for assistance with wording and implementation
Checklist
devpnpm -r build,pnpm testandpnpm -r typecheckpass locallypnpm changeset) if this changescore,widgetorserver