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

Add custom translatable error messages from Cognito #949

Merged
merged 5 commits into from
Dec 8, 2021

Conversation

ErikCH
Copy link
Contributor

@ErikCH ErikCH commented Dec 6, 2021

Issue #, if available:
#255

Description of changes:
This fix will allow users to overwrite any error or validation error message in the application. For example a user can overwrite the error message when a user does not exist when logging in.

I18n.putVocabularies(translations);
    I18n.setLanguage('ja');
    I18n.putVocabulariesForLanguage('ja', {
      'Sign In': 'Sign In Custom',
      'User does not exist.': 'Error with your user',
    });

image

You can see an example of this in our i18n feature test.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@changeset-bot
Copy link

changeset-bot bot commented Dec 6, 2021

🦋 Changeset detected

Latest commit: 1520b6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@aws-amplify/ui-angular Patch
@aws-amplify/ui-react Patch
@aws-amplify/ui-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-949.d3inl0muob87le.amplifyapp.com

@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-949.d3inl0muob87le.amplifyapp.com

@ErikCH ErikCH temporarily deployed to ci December 7, 2021 01:02 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 01:02 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 01:02 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 01:18 Inactive
@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-949.d3inl0muob87le.amplifyapp.com

@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-949.d3inl0muob87le.amplifyapp.com

Comment on lines +30 to +47
And(
'the {string} input is in {string} and I type the wrong username or password',
(label: string, language: string) => {
cy.findByPlaceholderText(translations[language][label].trim()).type(
'UNKNOWN@UNKNOWN.com'
);
}
);

And(
'the {string} button is in {string} and I click it',
(label: string, language: string) => {
cy.findByRole('button', {
name: translations[language][label].trim(),
}).click();
}
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New helpers for translations

Copy link
Contributor

@reesscot reesscot left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wlee221 wlee221 left a comment

Choose a reason for hiding this comment

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

🚢

@ErikCH ErikCH temporarily deployed to ci December 7, 2021 23:25 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 23:25 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 23:25 Inactive
@ErikCH ErikCH temporarily deployed to ci December 7, 2021 23:48 Inactive
@ErikCH ErikCH merged commit aec9a94 into main Dec 8, 2021
@ErikCH ErikCH deleted the i18n-error-message-update branch December 8, 2021 15:47
@github-actions github-actions bot mentioned this pull request Dec 8, 2021
@JacobDel
Copy link

JacobDel commented Dec 29, 2023

Why is there no support for react-native?
The translate component isn't even available in @aws-amplify/ui-react-native.
Are there plans to do so?

Is there a list of possible errors (errors thrown by aws cognito provider, not the js Authenticator)

What if for some reason the aws amplify error changes from 'User does not exist.' to something else? Isn't there a more robust approach?

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

Successfully merging this pull request may close these issues.

4 participants