File tree Expand file tree Collapse file tree
app/android/src/main/java/com/capacitorjs/plugins/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import android .content .pm .PackageInfo ;
66import android .net .Uri ;
77import androidx .activity .OnBackPressedCallback ;
8+ import androidx .appcompat .app .AppCompatDelegate ;
89import androidx .core .content .pm .PackageInfoCompat ;
10+ import androidx .core .os .LocaleListCompat ;
911import com .getcapacitor .JSObject ;
1012import com .getcapacitor .Logger ;
1113import com .getcapacitor .Plugin ;
@@ -130,7 +132,9 @@ public void toggleBackButtonHandler(PluginCall call) {
130132 @ PluginMethod
131133 public void getAppLanguage (PluginCall call ) {
132134 JSObject ret = new JSObject ();
133- ret .put ("value" , Locale .getDefault ().getLanguage ());
135+ LocaleListCompat appLocales = AppCompatDelegate .getApplicationLocales ();
136+ Locale appLocale = !appLocales .isEmpty () ? appLocales .get (0 ) : null ;
137+ ret .put ("value" , appLocale != null ? appLocale .getLanguage () : Locale .getDefault ().getLanguage ());
134138 call .resolve (ret );
135139 }
136140
You can’t perform that action at this time.
0 commit comments