Firebase Authentication Error in Other Languages

firebase authentication error in other languages

Firebase errors are not localized. You could request a feature for this via Firebase support.

What you could do instead is create your own localized messages based on the error codes provided. This is what FirebaseUI does:

  • FirebaseUI-ios

  • FirebaseUI-web

Or you could just simply use FirebaseUI-ios. It would save you a lot of time and effort.

how to translate the error code from Firebase Authentication?

The following line of code:

exception.getMessage();

Gets the exception message in english while the following line of code:

exception.getLocalizedMessage();

Gets a localized message. According to the official documentation regarding Throwable's getLocalizedMessage() method:

Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method, the default implementation returns the same result as getMessage().

How to change the language of the message sent in Firebase auth

thanks for @Frank van Puffelen, @Miyo Alpízar @Frederiko Cesar for thier anser in this question & this question

Firebase's error message are targeted at application developers, so are in English only. While we'd love to provide them in the same languages as we provide our documentation in, that will never cover all the languages of your users.

So you will have to detect the error in your code, log the error to a central system where you can inspect the problem and then show a localized error message to your user.

As far as I know there is no standardized way of doing that in Angular. But if there is, it'll be unrelated to Firebase.

How to properly display Firebase Auth error to user using Toast and Typescript?

The err object has a code property that you check check in your code, and a message property that you can display to the user.

So:

  ...
} catch (err) {
toast.show({
title: 'Cannot sign-up an account.',
status: 'error',
description: err.message,
});
}

See the Firebase documentation on sending a password reset email that has an example of accessing these two properties.

Also see:

  • Firebase error messages in different languages?
  • list of all auth/ errors for firebase web API
  • Does Firebase Auth return an Error Code if authentification is not successful?

How can I use firebase's language code (myFirebase.auth().languageCode) in my action link URL in Firebase Authentication email template?

In case if anyone of you guys wonders what I did.

So, I wrote a feature request to Firebase support and this was the last email I got from their support team.

Hello Erwin

Unfortunately there is no more customization but the one that I've shared with you, however I made sure to raise a feature request, asking to add more customization features to the email action links and handlers

Our engineers will certainly consider adding this to Firebase Authentication, keep an eye on the Firebase Release Notes to be informed of the latest from Firebase. Thanks again for sharing your thoughts!

Please write back if you have any other consult.

Cheers, X

At this point of time, I am still relying on the workaround solution that I have mentioned in my question. Hope it helps!



Related Topics



Leave a reply



Submit