0

I'd like to localize or event better change the prompt text of User Consent API.

Default behavior:

So instead of Allow example to read the message below and enter the code I want it to be translated in other languages, based on my app's locale not based on device's locale.

Tornike Kurdadze
  • 955
  • 2
  • 10
  • 24
  • Does this answer your question? [change the language of runtime permission](https://stackoverflow.com/questions/36034048/change-the-language-of-runtime-permission) – user18309290 Aug 05 '22 at 05:56
  • I want to change the translation based on my app's locale not device's locale, but I guess it's not possible – Tornike Kurdadze Aug 05 '22 at 06:07

1 Answers1

1

This view's translation is handled by the library gms:play-services-auth-api-phone.
Didn 't find any information in their documentation explaining how to customize the message displayed in the bottomSheetView.

About the language of the message, it should update automatically depending on the phone's language.

Since you're receiving an intent from another app, chances are that you won't be able to 'force' a locale sadly.

The only thing you could try is to "force" the Locale on the Android part in your FlutterActivity but note that it could have unpredicted consequences over your app, and I really doubt it'll work.

private void setLocale(Locale locale){
    SharedPrefUtils.saveLocale(locale); // optional - Helper method to save the selected language to SharedPreferences in case you might need to attach to activity context (you will need to code this)
    Resources resources = getResources();
    Configuration configuration = resources.getConfiguration();
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
        configuration.setLocale(locale);
    } else{
        configuration.locale=locale;
    }
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N){
        getApplicationContext().createConfigurationContext(configuration);
    } else {
        resources.updateConfiguration(configuration,displayMetrics);
    }
}

Code retrieved from this StackOverflow post, credit to the author.

FDuhen
  • 4,097
  • 1
  • 15
  • 26
  • Thanks for the answer, unfortunately, localization works based on device's locale and not based on my app's locale, it's would be nice to have a simple parameter to specify the locale at runtime. – Tornike Kurdadze Aug 05 '22 at 06:15
  • Edited my answer to give you a snippet you could use to try to force the locale at runtime, even if I doubt it'll work – FDuhen Aug 05 '22 at 06:23
  • Sadly, programmatically changing the locale isn't working. – Tornike Kurdadze Aug 05 '22 at 06:51