【问题标题】:Xamarin android App - Changing device language to "he-IL" does not set UICultureXamarin android App - 将设备语言更改为“he-IL”不会设置 UICulture
【发布时间】:2020-11-09 07:53:02
【问题描述】:

我在 Visual Studio 2019 上有一个 Xamarin 表单 (v5.0.0.1558pre3) android 应用程序 我希望我的应用支持不同的语言,所以我做了以下操作:

  1. 我为默认语言资源创建了 AppResources.resx,并为我的希伯来语创建了 AppResources.he-IL.resx,其中只有一个 resx 文件,如下所示:

  1. 我已将设备上的语言设置为希伯来语。

  2. 然后我将所有字符串设置为使用资源:

    Text="{x:静态资源:AppResources.MonthlyUsage}"

当我启动应用程序时,它仍会加载默认的 AppResources.resx 值。

其他语言(如 fr-FR)设置得很好。

【问题讨论】:

    标签: android xaml xamarin localization


    【解决方案1】:

    我认为在 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。

    【讨论】:

    • 完美!谢谢,正是我需要的。奇迹般有效。因此,为了澄清,需要在 android 项目上将 _ 替换为 - 并将 iw_IL 更改为 he-IL。我已经在 MainActivity OnCreate 中完成了。
    猜你喜欢
    • 1970-01-01
    • 2011-02-05
    • 1970-01-01
    • 2021-01-31
    • 2015-11-17
    • 1970-01-01
    • 2014-01-11
    • 2022-06-23
    • 1970-01-01
    相关资源
    最近更新 更多