firebase / FirebaseUI-Flutter

Apache License 2.0
92 stars 81 forks source link

feat(ui_auth): export `localizedErrorText` #189

Closed lesnitsky closed 7 months ago

lesnitsky commented 7 months ago

When ErrorText.localizeError is used, it becomes a single source of truth. This means all error messages should be localized by developer. A subset of errors is already localized by Firebase UI, so localizedErrorText that is used internally is now public and could be used inside ErrorText.localizeError.

Example:

ErrorText.localizeError = (BuildContext context, FirebaseAuthException e) {
  if (e.code == "user-not-found" || e.code == "wrong-password") return "Wrong credentials";

  final defaultLabels = FirebaseUILocalizations.labelsOf(context);
  return localizedErrorText(e.code, defaultLabels);
}

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?