问题描述
我在Visual Studio 2019上有Xamarin表单(v5.0.0.1558pre3)android应用程序 我希望我的应用程序支持不同的语言,所以我做了以下事情:
-
我已将设备上的语言设置为希伯来语。
-
然后我将所有字符串设置为使用资源:
Text =“ {x:静态资源:AppResources.MonthlyUsage}”
启动应用程序时,它仍会加载默认的AppResources.resx值。
其他语言(例如fr-FR)的设置也很好。
解决方法
我认为在Android上,您需要像这样检查当前设置的Android语言环境:
var locale = Java.Util.Locale.Default;
Xamarin论坛上有一个线程描述了类似的问题:https://forums.xamarin.com/discussion/74484/app-crashes-when-language-set-to-hebrew
似乎您还必须将_
替换为-
,并且似乎需要将iw_IL
更改为he_IL
。
您将不得不在启动时检测到此情况并相应地调整CurrentUICulture。