Studio: Translate Studio Assistant Welcome messages - #483
Conversation
| path: '/studio-app/ai-assistant/welcome', | ||
| path: `/studio-app/ai-assistant/welcome?locale=${ encodeURIComponent( locale ) }`, | ||
| apiNamespace: 'wpcom/v2', | ||
| params: { locale }, |
There was a problem hiding this comment.
The problem with passing the parameter like this is that the request URL gets formatted like so:
wpcom/v2/studio-app/ai-assistant/welcome?_locale=pl with underscore which breaks the request to the API and the translation does not come through
There was a problem hiding this comment.
Why not adjust the code responsible for that in the custom request() function?
studio/src/components/auth-provider.tsx
Line 123 in 09f7f3d
There was a problem hiding this comment.
Thanks for the review @wojtekn ! Interesting, looking at this setting, I see that when you switch to a language other than English, it appends the locale parameter to all requests going to different endpoints. If I remove the locale parameter from the /welcome endpoint, I see it also gets appended:
Looking at the original PR where this was introduced - https://github.com/Automattic/local-environment/pull/91 - this seems to have been done so that the locale is set for the duration of the API call.
In regards to this, I have the following question:
- Why do we need to set a specific locale for all of these API calls? From my understanding, we are not returning anything locale-specific in any of these endpoints beside the
/welcomeendpoint and even for the/welcomeendpoint it does not seem to work?
There was a problem hiding this comment.
Why do we need to set a specific locale for all of these API calls? From my understanding, we are not returning anything locale-specific in any of these endpoints beside the /welcome endpoint and even for the /welcome endpoint it does not seem to work?
I would think it's to let API endpoints return localized error messages.
There was a problem hiding this comment.
I see, that makes sense. So if I am testing this correctly, I am seeing the following:
- When I pass
localeinto/welcomeendpoint, I am getting the translations of the messages but I am not getting localized error messages - When I pass
_locale, I am getting only the localized error messages and not the translated messages - The only way I found to make this work for both is to pass both
localeand_locale- example of the URL:
I am seeing two options for this case:
- either we pass both as mentioned above if we want both error messages and the welcome messages
- OR we pass only
localefor this specific endpoint since we don't really display the localized error messages that come from the endpoint for the welcome messages.
What do you think?
There was a problem hiding this comment.
Update: after Slack discussions, we will proceed with the fix of the API endpoint for the welcome messages. I will update here once it is done
There was a problem hiding this comment.
@wojtekn I prepared a fix here: D158963-code and it needs to be tested in combination with this PR (the testing steps in the PR are updated).
Let me know what you think!
|
Works as expected. |
Closes https://github.com/Automattic/dotcom-forge/issues/8279
Proposed Changes
This PR ensures that the welcome messages for which we have translated the strings in GlotPress are translated in Studio Assistant:
Testing Instructions
npm startAssistanttabPre-merge Checklist