My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
Check into the modules, you will get to see all apps list that is installed on your Android phone. Step 4: Select one of the app which you want to edit the language. With the help of the app interface, choose the desired language from the given options and click on the confirm button.
You can provide support for different locales by using the resources directory in your Android project. You can specify resources tailored to the culture of the people who use your app. You can provide any resource type that is appropriate for the language and culture of your users.
Get system language
Resources.getSystem().getConfiguration().locale.getLanguage();
Get app language
String currentLang = Locale.getDefault().getLanguage();
This is the correct answer: getResources().getConfiguration().locale
Kotlin - Android X:
val currentSysLocale = Resources.getSystem().getConfiguration().locales[0]
val currentAppLocale = Locale.getDefault().getLanguage()
Log.d("sys locale","$currentSysLocale")
Log.d("app locale","$currentAppLocale")
To Get System Language Use this:
String DeviceLang =Resources.getSystem().getConfiguration().locale.getLanguage();
And For the Application Language Use this:
String AppLang = Resources.getConfiguration().locale.getLanguage();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With