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

Get i18n error messages on @aws-amplify/ui-react #255

Closed
xavierraffin opened this issue Oct 1, 2020 · 6 comments
Closed

Get i18n error messages on @aws-amplify/ui-react #255

xavierraffin opened this issue Oct 1, 2020 · 6 comments
Assignees
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs feature-request Request a new feature I18n An issue for a missing Localization / Translation / Internationalization

Comments

@xavierraffin
Copy link

Is your feature request related to a problem? Please describe.

Error message are not translated when i18n lang changes when using UI from @aws-amplify/ui-react.
Plus there is no reliable list to know what possible message has to be translated.

There is an old list in packages/aws-amplify-react/src/AmplifyI18n.tsx but it was for the legacy aws-amplify-react package.
The list is incomplete (Eric said):

The problem is that those languages have ~41 translated strings, while the new UI components have ~65, many new & others being different from what existed before.

Additionally errors from Cognito should have a way to be translated.
Example:
1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6

This type of message is complicated to translate.

Describe the solution you'd like

I like to have the full list of Translation string somewhere. (like amplify-ui-compomnents/src/common/Translation.tsx).

Having translation ready (like it was the case on aws-amplify-react on AmplifyI18n.tsx) will be ideal.
And documenting the supported languages will be great.

Having error messages from Cognito reliably translated. Not directly displayed to user. Why not asking Cognito to return an error code and use that fro English and non English translation with string controlled on Amplify side

Describe alternatives you've considered

Painfully looking in the code and testing. Then adding translations.
So far I added:

export const strings = {
    fr: {
        "1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6": "Le mot de passe doit faire au moins 6 caractères.",
        "Username cannot be empty": "Le nom d'utilisateur doit être renseigné",
        "User does not exist." : "L'utilisateur n'existe pas.",
        "An account with the given email already exists.": "Un compte avec cette adresse couriel existe déjà.",
        "User is disabled.": "L'utilisateur est désectivé.",
        "Access Token has been revoked": "Le jeton d'accès a été révoqué"
    }
}
@xavierraffin
Copy link
Author

In aws-amplify/amplify-js#4979 Eric explained why he did not do translation at that time in his PR. Maybe now is time to finish the job?

@harrysolovay
Copy link

Is this the list of possible translations which you would like better-documented?

@xavierraffin
Copy link
Author

I am not sure for that one.
The initial ask was about the i18n translation provided off the shelf by Amplify before new components: https://github.com/aws-amplify/amplify-js/blob/master/packages/aws-amplify-react/src/AmplifyI18n.tsx

And the second ask is a translation of the error from Cognito.
For that I understand that having an error code from Cognito is something that will help. I already talk about that to ouli@ (AWS login) and they have plan to do that in the future

@Immutible
Copy link

I'm facing similar issues with translations. A complete list wouldn't be enough for covering all the cases because the error messages can also include input values. E.g.

2 validation errors detected: Value 'test test' at 'userName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}]+; Value 'test test' at 'userAlias' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}]+

In above case email is used as a userName value.

@ErikCH ErikCH transferred this issue from aws-amplify/amplify-js Aug 25, 2021
@ErikCH ErikCH added Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs feature-request Request a new feature labels Aug 25, 2021
@ericclemmons ericclemmons added the Authenticator An issue or a feature-request for an Authenticator UI Component label Oct 6, 2021
@ericclemmons ericclemmons added the I18n An issue for a missing Localization / Translation / Internationalization label Oct 6, 2021
@eddiekeller
Copy link
Contributor

This remains an issue, even in the new version of the authenticator. Cognito error messages do not get translated. Since user input is often included in the message, I'm guessing what we would have to hook in to is the error type. Off the top of my head, I'm not sure if Cognito reuses error types, though. If they do, then that would not be a reliable solution.

@ericclemmons
Copy link
Contributor

This is also a short-coming of I18n being little more than a map.

Previous implementations relied on pattern-matching to translate errors:

https://github.com/aws-amplify/amplify-js/blob/853adc7554f0a61922e3348d3626c73a5166266d/packages/aws-amplify-react/src/AmplifyMessageMap.tsx

@Milan-Shah Milan-Shah added ready-for-planning pending-triage Issue is pending triage bug Something isn't working and removed feature-request Request a new feature pending-triage Issue is pending triage labels Nov 23, 2021
@Milan-Shah Milan-Shah added Service Team An issue which requires a collaboration with a service team feature-request Request a new feature and removed Service Team An issue which requires a collaboration with a service team bug Something isn't working labels Dec 2, 2021
@ErikCH ErikCH closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs feature-request Request a new feature I18n An issue for a missing Localization / Translation / Internationalization
Projects
None yet
Development

No branches or pull requests

7 participants