-
Notifications
You must be signed in to change notification settings - Fork 18
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
Studio: Translate Studio Assistant Welcome messages #483
Studio: Translate Studio Assistant Welcome messages #483
Conversation
apiNamespace: 'wpcom/v2', | ||
params: { 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not adjust the code responsible for that in the custom request()
function?
studio/src/components/auth-provider.tsx
Line 123 in 09f7f3d
const localeParamName = |
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 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
/welcome
endpoint and even for the/welcome
endpoint it does not seem to work?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that makes sense. So if I am testing this correctly, I am seeing the following:
- When I pass
locale
into/welcome
endpoint, 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
locale
and_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
locale
for 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 start
Assistant
tabPre-merge Checklist