Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get application language and device language separately in android?

My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?

like image 659
mob_web_dev Avatar asked Mar 29 '17 11:03

mob_web_dev


People also ask

Can I change the language of a single app Android?

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.

Can an app use multiple languages?

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.


4 Answers

Get system language

Resources.getSystem().getConfiguration().locale.getLanguage();

Get app language

String currentLang = Locale.getDefault().getLanguage();
like image 153
Elsunhoty Avatar answered Oct 05 '22 02:10

Elsunhoty


This is the correct answer: getResources().getConfiguration().locale

like image 33
Ahmad Shahwaiz Avatar answered Oct 05 '22 03:10

Ahmad Shahwaiz


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")
like image 32
Alessandro Ornano Avatar answered Oct 05 '22 02:10

Alessandro Ornano


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();
like image 27
Kaushik Khambhadiya Avatar answered Oct 05 '22 01:10

Kaushik Khambhadiya