amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Authenticator - Customization & Localization of server error messages

Open afnx opened this issue 1 year ago • 5 comments

I can't find a way to customize the error messages received from Cognito based on the device’s locale. The following is one of the messages I'm talking about:

flutter: ERROR | Authenticator | Error in AuthBloc: UserNotFoundException {
  "message": "User does not exist.",
  "underlyingException": "UserNotFoundException {\n  message=User does not exist.,\n}"
}

The server response is being displayed directly through material banners without any possibility for modifications. An ideal approach would be creating a new .arb file for all server exception types, which allows for overrides. This would enable display of localized texts instead of plain server messages.

afnx avatar Jun 29 '23 05:06 afnx

~~@afnx - I believe this is being tracked here https://github.com/aws-amplify/amplify-ui/issues/3368. Please feel free to give that issue a 👍 (it helps us quickly gauge interest in an issue).~~

We will use this issue to track the ability to customize/localize error messages

Jordan-Nelson avatar Jun 29 '23 13:06 Jordan-Nelson

@Jordan-Nelson I see someone made a PR for this. Is that the fix, or is there another way to localize on Flutter? I've seen the other issues and they solve the problem for React but I was not able to find something for Flutter. Quick update would be much appreciated <3

RamiMezghani avatar Jan 30 '24 15:01 RamiMezghani

Hello @RamiMezghani - I took a look at the PR. It looks like it would add localization for a handful of error messages that can be returned from Cognito. There are two main drawbacks with this approach:

  1. It doesn't support all messages/scenarios.
  2. It relies on the error string from Cognito never changing, which may not be the case.

This would be step in the right direction but I think we will want to see if there is a more comprehensive solution.

This is in our backlog of feature requests. I do not have a timeline on when this could be completed at the moment but we will share updates here when we have them.

Jordan-Nelson avatar Jan 30 '24 17:01 Jordan-Nelson

@Jordan-Nelson Thanks for clarifying. Can I assume that as of right now, we cannot translate the errors from Cognito on Flutter? I do not seem to find a workaround, can you confirm?

RamiMezghani avatar Jan 30 '24 17:01 RamiMezghani

@RamiMezghani That is correct. I am not aware of a workaround.

Jordan-Nelson avatar Jan 30 '24 18:01 Jordan-Nelson