Skip to content

Commit

Permalink
fix(auth, web): use the device language when using setLanguageCode
Browse files Browse the repository at this point in the history
…with null (#11905)

* fix(auth, web): use the device language when using setLanguageCode with null

* fix doc
  • Loading branch information
Lyokone committed Nov 17, 2023
1 parent 1708472 commit f9322b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Expand Up @@ -362,18 +362,13 @@ class FirebaseAuth extends FirebasePluginPlatform {
await _delegate.sendSignInLinkToEmail(email, actionCodeSettings);
}

/// When set to null, the default Firebase Console language setting is
/// applied.
/// When set to null, sets the user-facing language code to be the default app language.
///
/// The language code will propagate to email action templates (password
/// reset, email verification and email change revocation), SMS templates for
/// phone authentication, reCAPTCHA verifier and OAuth popup/redirect
/// operations provided the specified providers support localization with the
/// language code specified.
///
/// On web platforms, if `null` is provided as the [languageCode] the Firebase
/// project default language will be used. On native platforms, the device
/// language will be used.
Future<void> setLanguageCode(String? languageCode) {
return _delegate.setLanguageCode(languageCode);
}
Expand Down
Expand Up @@ -311,7 +311,11 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {

@override
Future<void> setLanguageCode(String? languageCode) async {
delegate.languageCode = languageCode;
if (languageCode == null) {
delegate.useDeviceLanguage();
} else {
delegate.languageCode = languageCode;
}
}

@override
Expand Down
Expand Up @@ -687,7 +687,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
auth_interop.connectAuthEmulator(jsObject, origin);

/// Sets the current language to the default device/browser preference.
void useDeviceLanguage() => jsObject.useDeviceLanguage();
void useDeviceLanguage() => auth_interop.useDeviceLanguage(jsObject);

/// Verifies a password reset [code] sent to the user by email
/// or other out-of-band mechanism.
Expand Down
Expand Up @@ -236,6 +236,9 @@ external PromiseJsImpl<void> updateProfile(
UserProfile profile,
);

@JS()
external void useDeviceLanguage(AuthJsImpl auth);

/// https://firebase.google.com/docs/reference/js/auth.md#multifactor
@JS()
external MultiFactorUserJsImpl multiFactor(
Expand Down Expand Up @@ -269,7 +272,6 @@ abstract class AuthJsImpl {
Func0? opt_completed,
]);
external PromiseJsImpl<void> signOut();
external void useDeviceLanguage();
}

@anonymous
Expand Down

0 comments on commit f9322b6

Please sign in to comment.