Skip to content
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

feat: introduce i18n to error page #669

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

anitavincent
Copy link
Contributor

What does this PR do? *

introduces i18n to error page

How to test it? *

To check full page error: https://anita--teamadmin.myvtex.com/admin

If your locale is pt-br some strings should be in portuguese (but not all)

for client side error:
https://anita1--teamadmin.myvtex.com/admin/io-manager/explode/?forceLogs=true

Copy link
Contributor

vtex-io-ci-cd bot commented Nov 11, 2024

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

vtex-io-docs-bot bot commented Nov 11, 2024

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

Copy link
Contributor

@lucasaarcoverde lucasaarcoverde left a comment

Choose a reason for hiding this comment

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

LGTM, just a question

@@ -0,0 +1 @@
{}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we need those translations before merging the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now it just falls back to english so nothings is changed

Copy link
Member

@marcelovicentegc marcelovicentegc left a comment

Choose a reason for hiding this comment

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

Folks, I'm concerned with one aspect of these changes: a lot of times Render breaks is when it's going through its lifecycle that, among other things, injects the locale in the context.

This means that on real-world scenarios, we might just render the title IDs on the page with this approach in case the language is not available. This is why most of these strings are hardcoded and do not rely on react-intl.

@anitavincent
Copy link
Contributor Author

Folks, I'm concerned with one aspect of these changes: a lot of times Render breaks is when it's going through its lifecycle that, among other things, injects the locale in the context.

This means that on real-world scenarios, we might just render the title IDs on the page with this approach in case the language is not available. This is why most of these strings are hardcoded and do not rely on react-intl.

There is a function that uses the english strings as fallback, the function could also handle an undefined locale and fall back to english. Isn't that enough?

@marcelovicentegc
Copy link
Member

marcelovicentegc commented Nov 22, 2024

Folks, I'm concerned with one aspect of these changes: a lot of times Render breaks is when it's going through its lifecycle that, among other things, injects the locale in the context.
This means that on real-world scenarios, we might just render the title IDs on the page with this approach in case the language is not available. This is why most of these strings are hardcoded and do not rely on react-intl.

There is a function that uses the english strings as fallback, the function could also handle an undefined locale and fall back to english. Isn't that enough?

If we do have a fallback mechanism in place, yes, we're good 😉

Copy link

@iago1501 iago1501 Nov 25, 2024

Choose a reason for hiding this comment

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

@anitavincent , why aren't we using the messages builder instead?

Copy link
Member

@marcelovicentegc marcelovicentegc left a comment

Choose a reason for hiding this comment

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

LGTM!


export function getMessages(locale: string) {
const localeMessages = (locale && messages[locale]) || {}
const fallbackMessages = messages['en-US']
Copy link
Member

Choose a reason for hiding this comment

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

This is key and it answers @iago1501's question ❤️

Copy link

@iago1501 iago1501 Nov 25, 2024

Choose a reason for hiding this comment

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

@marcelovicentegc If it's because of the fallback we could simply use the available languages in vtex.store as an example of languages that we should take care of in stores, for example https://github.com/vtex-apps/store/tree/master/messages

or talking about admin, the ones that we have in vtex.admin-pages: https://github.com/vtex-apps/admin-pages/tree/master/messages

My main concern is that using the message's builder is one of our patterns when talking about translations, we have the messages folder and all translations are inside it, with this approach, talking about scaling, if any other component needs translation, we would have to add a messages folder for the component instead of centering in a single place and this logic would be replicated 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I see your point @iago1501, but given that this application didn't have translations until this day while being around for many years, I wouldn't be concerned about adopting a pattern that we might not need by the end of the day, and that we know it's the entry point for one of the most frequent errors we experience in the Admin given that the messages service itself didn't scale as we expected.

For this same reason, it occurs to me that we should rather not rely on the messages service nor its builder, specially on a mission critical component such as this application, when we could otherwise organize translations where needed (the error component) and skip all complexity that using the messages builder involves (triggering the messages service lifecycle just to fetch some strings stored elsewhere while it could just to be packaged with the application itself?).

It occurs to me that using the messages service could break the error component itself quite frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants