amplify-flutter
amplify-flutter copied to clipboard
Authenticator - Customization & Localization of server error messages
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 - 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 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
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:
- It doesn't support all messages/scenarios.
- 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 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 That is correct. I am not aware of a workaround.