In xamarin, how to get the current language of the device for Android?

こ雲淡風輕ζ 提交于 2021-02-17 22:18:08

问题


How could I get the current language of the device in Xamarin (for Android)?

Got the language with context.Resources.Configuration.Locale.Language


回答1:


Here's a cross platform version I use. Obviously you can pull whatever property you need from CurrentUICulture.

return CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

Maybe it will help someone else.




回答2:


This appears to be what you are looking for: http://androidapi.xamarin.com/?link=T%3aSystem.Globalization.RegionInfo

The RegionInfo class appears to have access for various ways to read that language information and use in your comparisons.

Based on this question, I went to the Xamarin documentation looking for the answer: Get the current language in device



来源:https://stackoverflow.com/questions/15618699/in-xamarin-how-to-get-the-current-language-of-the-device-for-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!