Switching language of Firebase phone sign-in UI on Android

665 views
Skip to first unread message

Vijayendra Vasu

unread,
Feb 16, 2020, 11:54:46 AM2/16/20
to Firebase Google Group
Hi,

I am developing and Android native application that allows the user to choose the UI language in the first page. All other pages are then displayed in the chosen UI.

The third page of the app requires the user to sign-in using the Firebase phone auth UI (version com.google.firebase:firebase-auth:19.2.0). Unfortunately, the phone auth UI always seems to display in the phone / system language. In other words, if the language of the phone is English, the phone auth UI is always displayed in English. Even if the user has chosen Hindi as the preferred language in the first page, I couldn't find a way to instruct the Firebase phone auth UI to display in Hindi. I looked at the FirebaseApp documentaion and also at the source code, but couldn't figure it out.

Is there a way to display the Firebase phone auth UI in a language different from the system language?

Thanks in advance for any help or pointers!

Sam Stern

unread,
Feb 18, 2020, 1:43:40 PM2/18/20
to Firebase Google Group
Hi there,

So if I understand this situation correctly your app has a language selection screen that is different from the system-wide language selection screen?  FirebaseUI uses the system locale to select the right translations.  As far as I know there is no way for us to change this at runtime, although if you know of a way I would consider it as a feature request!

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/997ee13e-2393-4118-8f99-d3fb1ac1d3d0%40googlegroups.com.

Dan I

unread,
Feb 18, 2020, 3:14:25 PM2/18/20
to fireba...@googlegroups.com
Try changing Application locale. That might do the trick

Vijayendra Vasu

unread,
Feb 19, 2020, 10:57:01 AM2/19/20
to Firebase Google Group
@Dan, I have switched application locale, to no avail. I am following the suggestions in this article to switch language, but the auth UI is not honoring the application's locale.
https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758

I have debugged through Firebase App code, and couldn't find a way either.


On Wednesday, February 19, 2020 at 1:44:25 AM UTC+5:30, Dan I wrote:
Try changing Application locale. That might do the trick

On Wed, Feb 19, 2020, 12:13 AM 'Sam Stern' via Firebase Google Group <fireba...@googlegroups.com> wrote:
Hi there,

So if I understand this situation correctly your app has a language selection screen that is different from the system-wide language selection screen?  FirebaseUI uses the system locale to select the right translations.  As far as I know there is no way for us to change this at runtime, although if you know of a way I would consider it as a feature request!

- Sam

On Sun, Feb 16, 2020 at 8:54 AM Vijayendra Vasu <vijt...@gmail.com> wrote:
Hi,

I am developing and Android native application that allows the user to choose the UI language in the first page. All other pages are then displayed in the chosen UI.

The third page of the app requires the user to sign-in using the Firebase phone auth UI (version com.google.firebase:firebase-auth:19.2.0). Unfortunately, the phone auth UI always seems to display in the phone / system language. In other words, if the language of the phone is English, the phone auth UI is always displayed in English. Even if the user has chosen Hindi as the preferred language in the first page, I couldn't find a way to instruct the Firebase phone auth UI to display in Hindi. I looked at the FirebaseApp documentaion and also at the source code, but couldn't figure it out.

Is there a way to display the Firebase phone auth UI in a language different from the system language?

Thanks in advance for any help or pointers!

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

On Wednesday, February 19, 2020 at 1:44:25 AM UTC+5:30, Dan I wrote:
Try changing Application locale. That might do the trick

On Wed, Feb 19, 2020, 12:13 AM 'Sam Stern' via Firebase Google Group <fireba...@googlegroups.com> wrote:
Hi there,

So if I understand this situation correctly your app has a language selection screen that is different from the system-wide language selection screen?  FirebaseUI uses the system locale to select the right translations.  As far as I know there is no way for us to change this at runtime, although if you know of a way I would consider it as a feature request!

- Sam

On Sun, Feb 16, 2020 at 8:54 AM Vijayendra Vasu <vijt...@gmail.com> wrote:
Hi,

I am developing and Android native application that allows the user to choose the UI language in the first page. All other pages are then displayed in the chosen UI.

The third page of the app requires the user to sign-in using the Firebase phone auth UI (version com.google.firebase:firebase-auth:19.2.0). Unfortunately, the phone auth UI always seems to display in the phone / system language. In other words, if the language of the phone is English, the phone auth UI is always displayed in English. Even if the user has chosen Hindi as the preferred language in the first page, I couldn't find a way to instruct the Firebase phone auth UI to display in Hindi. I looked at the FirebaseApp documentaion and also at the source code, but couldn't figure it out.

Is there a way to display the Firebase phone auth UI in a language different from the system language?

Thanks in advance for any help or pointers!

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

On Wednesday, February 19, 2020 at 1:44:25 AM UTC+5:30, Dan I wrote:
Try changing Application locale. That might do the trick

On Wed, Feb 19, 2020, 12:13 AM 'Sam Stern' via Firebase Google Group <fireba...@googlegroups.com> wrote:
Hi there,

So if I understand this situation correctly your app has a language selection screen that is different from the system-wide language selection screen?  FirebaseUI uses the system locale to select the right translations.  As far as I know there is no way for us to change this at runtime, although if you know of a way I would consider it as a feature request!

- Sam

On Sun, Feb 16, 2020 at 8:54 AM Vijayendra Vasu <vijt...@gmail.com> wrote:
Hi,

I am developing and Android native application that allows the user to choose the UI language in the first page. All other pages are then displayed in the chosen UI.

The third page of the app requires the user to sign-in using the Firebase phone auth UI (version com.google.firebase:firebase-auth:19.2.0). Unfortunately, the phone auth UI always seems to display in the phone / system language. In other words, if the language of the phone is English, the phone auth UI is always displayed in English. Even if the user has chosen Hindi as the preferred language in the first page, I couldn't find a way to instruct the Firebase phone auth UI to display in Hindi. I looked at the FirebaseApp documentaion and also at the source code, but couldn't figure it out.

Is there a way to display the Firebase phone auth UI in a language different from the system language?

Thanks in advance for any help or pointers!

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Vijayendra Vasu

unread,
Feb 19, 2020, 10:57:01 AM2/19/20
to Firebase Google Group
Correct - my app has a language selelction screen that is different from the system-wide screen. This is not uncommon in Indian apps, especially those aimed at semi-urban or rural audiences - many people have no idea where the system-wide language selection screen is, and adding new languages at a system level is a cumbersome process (sometimes requires adding a language pack). So, apps often provide an easy way to switch between languages (see the attached screenshot of WhatsApp's language switching UI).

May I please know how / where I request this feature from Firebase?

Thanks!
Vij
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
WhatsApp - switch languages.png

Sam Stern

unread,
Feb 19, 2020, 12:26:28 PM2/19/20
to Firebase Google Group
Thanks for the context.  If you want to request the feature, you can do so here:

However you will take the extra step of showing me how to do it or I will have to close the issue as infeasible.  Right now we rely fully on the resources system to resolve languages.  We have Layout XML files that reference "@string" resources which are present in many languages.  Making a sweeping code change to resolve these in Java rather than implicitly though the resources system is not a reasonable change.

- Sam

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/9ab37b26-8432-4711-9ab3-b1a61ee2d6d6%40googlegroups.com.

Vijayendra Vasu

unread,
Feb 20, 2020, 10:07:14 AM2/20/20
to Firebase Google Group
Thanks! I will make a feature request on the GitHub issues page.

There is no need to load strings from Java or any other custom method other than from the normal way @string resources are loaded. Details of how to switch languages can be found here - this article sounds scary, but the implementation is not complicated and works well. In essence, we need to override the attachBaseContext method of the base activity auth UI activities, and in this override, change the context to contain the user-specified locale. Once this is done, the layout files of the activity will automatically load the resources in the user-specified language (I know the localized strings already exist, because the auth UI shows these strings when the phone language is changed).

The one question that I have is about the right way for the caller of the auth ui to specify the desired locale. If the locale is specified as a parameter in the auth ui builder, I am not sure the intent (and therefore the user-specified locale) is available when the attachBaseContext method of the auth UI activity is called or not - I am not sure what the best approach for parameter passing is.

I will be happy to work with you on the implementation.

Thanks,
Vij

Sam Stern

unread,
Feb 20, 2020, 12:12:07 PM2/20/20
to Firebase Google Group
Thanks for the information!  Sounds like we have a path forward.  If you file an issue on GitHub explaining what needs to change in attachBaseContext I can worry about plumbing the preference in from the AuthUI builder.

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/60382698-7c9c-4724-8816-32530cfe7d55%40googlegroups.com.

Vijayendra Vasu

unread,
Feb 21, 2020, 1:08:55 PM2/21/20
to fireba...@googlegroups.com

Terrific! I will create the GitHub issue and let you know. Thank you very much!

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/Xfkk83y0FHw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAHafJBr1kKBVBKQoyDaOE-o4SPsYOWb7aZit1kw5SSfx3o738A%40mail.gmail.com.

 

Vijayendra Vasu

unread,
Feb 22, 2020, 1:08:29 PM2/22/20
to Firebase Google Group
Hi Sam,

I have created the following issue on GitHub: https://github.com/firebase/FirebaseUI-Android/issues/1742

I have included the snippet of code required to switch the language in the issue. I have also included in the code links to articles that explain what the code is doing and why it is required. Please do let me know if you need any other information or if can assist in any way.

Thank you very much for your help!

Regards,
Vasu
Reply all
Reply to author
Forward
0 new messages