Skip to content

language locale is not set after calling setLanguageCode & appears as "und" in Auth blocking function. #5825

Open
@russellwheatley

Description

@russellwheatley

[READ] Step 1: Are you in the right place?

Yes, right place.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 2022.3.1
  • Firebase Component: Auth (Database, Firestore, Storage, Functions, etc)
  • Component version: 22.3.1

[REQUIRED] Step 3: Describe the problem

language locale in auth blocking function is "und" which means undetermined. This is occuring even when setting the language code.

First reported on FlutterFire repo: firebase/flutterfire#12519

This is not an issue on firebas-ios-sdk.

Logcat shows why it is "und":

2024-04-03 09:50:57.889 26056-26147 System                  io.flutter.plugins.firebase.tests    W  Ignoring header X-Firebase-Locale because its value was null.

Steps to reproduce:

I have a repo with reproduction here: https://github.com/russellwheatley/firebase-android

Here are the steps taken from README:

  1. Update applicationId & namespace in app/build.gradle to your app in your firebase project.
  2. Update app/google-services.json to your firebase project.
  3. Run npm i in backend/functions directory followed by npm run deploy to deploy the cloud functions to your firebase project.
  4. Run the app on an emulator and press the button in the bottom right hand corner to set the language, create a user and trigger the cloud function.
  5. Head to the cloud function logs and observe the locale as authBeforeUserCreated {"locale":"und",....other properties}. This should be "en-US".

Relevant Code:

FirebaseApp app = FirebaseApp.getInstance();
            FirebaseAuth auth = FirebaseAuth.getInstance(app);

            auth.setLanguageCode("en-US");

            auth.createUserWithEmailAndPassword("[email protected]", "qwerty123").addOnCompleteListener(task -> {
                if (task.isSuccessful()) {
                    Log.d(TAG, "User created successfully");

                } else {
                    Log.d(TAG, "User creation failed");
                }
            });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions