【问题标题】:In xamarin, how to get the current language of the device for Android?在 xamarin 中,如何获取 Android 设备的当前语言?
【发布时间】:2013-03-15 03:56:13
【问题描述】:

如何在 Xamarin(适用于 Android)中获取设备的当前语言?

通过context.Resources.Configuration.Locale.Language获得语言

【问题讨论】:

标签: android xamarin


【解决方案1】:

这是我使用的跨平台版本。显然,您可以从 CurrentUICulture 中提取您需要的任何属性。

return CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

也许它会帮助别人。

【讨论】:

  • using System.Globalization; 请注意,这偶尔会出现错误。
  • @Wtower errr 什么错误??这对我的应用来说真的很重要!
【解决方案2】:

这似乎是您正在寻找的: http://androidapi.xamarin.com/?link=T%3aSystem.Globalization.RegionInfo

RegionInfo 类似乎可以访问各种方法来读取该语言信息并在您的比较中使用。

基于这个问题,我去 Xamarin 文档寻找答案: Get the current language in device

【讨论】:

  • 谢谢马丁。 RegionInfo 可以给我一些地区名称。我通过 context.Resources.Configuration.Locale.Language 获得了当前语言。
猜你喜欢
  • 1970-01-01
  • 2011-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-22
  • 1970-01-01
相关资源
最近更新 更多