Deb*_*ger 23 android locale localization setlocale
我的设备语言是英文的,我的应用程序语言是意大利语.那么我将如何以编程方式获得语言设备语言和应用程序语言?
Els*_*oty 43
获得系统语言
Resources.getSystem().getConfiguration().locale.getLanguage();
Run Code Online (Sandbox Code Playgroud)
获得应用语言
String CurrentLang = Locale.getDefault().getLanguage();
Run Code Online (Sandbox Code Playgroud)
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")
Run Code Online (Sandbox Code Playgroud)
获取系统语言使用这个:
String DeviceLang =Resources.getSystem().getConfiguration().locale.getLanguage();
Run Code Online (Sandbox Code Playgroud)
对于应用程序语言,请使用:
String AppLang = Resources.getConfiguration().locale.getLanguage();
Run Code Online (Sandbox Code Playgroud)