-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18n: Add AI Translations Banner #96733
base: trunk
Are you sure you want to change the base?
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~58 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~552 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
0f48c83
to
bf633e6
Compare
return; | ||
} | ||
|
||
const language = getLanguage( localeSuggestions?.[ 0 ]?.locale ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my test case I've changed my WordPress.com locale to Polish and my browser languages were set to Norwegian, Thai and Polish. Going to /home I got a banner asking to switch to Norwegian without a CTA. I think that it would be more consistent to change the logic to:
- If user locale is English and localeSuggestions contains AI Translated Locale - show the banner for the first suggested locale with the CTA.
- If user locale is contained in AI Translated Locale - show the banner for the user locale without the CTA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, it makes sense! I've updated the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works pretty well! I did find two more edge cases:
- When the
Display interface in English
checkbox is selected, the notification isn't being shown. - If my UI locale is set to an AI Translated Locale, but locale-guess doesn't return any of the AI translated locales, the notification also won't be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here're some test cases I can think of:
- UI locale is English, browser locales contain one of the AI locales - show the prompt for top detected browser locale, with CTA.
- UI locale is English, browser locales don't contain any of the AI locales - don't show the prompt
- UI locale is AI locale without the 'show english' checkbox, browser locales contain the AI locale - show the prompt for user locale, without CTA.
- UI locale is AI locale without the 'show english' checkbox, browser locales contain other AI locale - show the prompt for user locale, without CTA.
- UI locale is AI locale without the 'show english' checkbox, browser locales contain no AI locales - show the prompt for user locale, without CTA.
- UI locale is AI locale with the 'show english' checkbox - same as 3-5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- When the
Display interface in English
checkbox is selected, the notification isn't being shown.
Could you provide the exact steps you used for 1? I tested setting my UI to Polish with the Display Interface in English
preference and the banner displayed as expected.
- If my UI locale is set to an AI Translated Locale, but locale-guess doesn't return any of the AI translated locales, the notification also won't be shown.
Updated the logic to handle the case.
Here're some test cases I can think of:
These all seem to test well. Did you experience anything unexpected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide the exact steps you used for 1?
Can't reproduce it right now, so it might've a different case. I do see an issue with test case 7 (user locale is Norwegian with "show english" checkbox, browser locales are Thai, German, Dutch) where the notification shows a prompt for Thai with a CTA.
Updated the logic to handle the case.
Test case 5 fails for me. Steps to reproduce: sandbox public-api with code-D167396, set user locale to Norwegian Bokmal, set Chrome top browser languages to German / Dutch / Japanese, open the site home for a simple site. locale-guess API call returns de/ja/nl and the site home shows no notification and some card stuck in loading state. Tested both on calypso.live and locale instance.
Lastly, are the clicks on support link and /me/account link being captured as track events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lastly, are the clicks on support link and /me/account link being captured as track events?
Yes, CTA clicks are tracked as well as dismissing the notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't reproduce it right now, so it might've a different case. I do see an issue with test case 7 (user locale is Norwegian with "show english" checkbox, browser locales are Thai, German, Dutch) where the notification shows a prompt for Thai with a CTA.
I switched to reading the locale from the user object, rather than reading it from i18n-calypso
. With this change, we should now have the expected behavior with the "Display interface in English" checkbox.
Test case 5 fails for me. Steps to reproduce: sandbox public-api with code-D167396, set user locale to Norwegian Bokmal, set Chrome top browser languages to German / Dutch / Japanese, open the site home for a simple site. locale-guess API call returns de/ja/nl and the site home shows no notification and some card stuck in loading state. Tested both on calypso.live and locale instance.
I followed the steps for test case 5 and it works as expected. The infinite loading state of the card below that you mentioned is unrelated to the translations notice banner, but it makes me think that there might be some other problem on your end. Could you inspect the network request and see if anything is failing there?
Related to Automattic/i18n-issues#886
Proposed Changes
Preview:
Why are these changes being made?
Testing Instructions
/home/
./home/
.Pre-merge Checklist