android - 阿拉伯语字符串未显示在 Xamarin Forms 应用程序中

标签 android xamarin

我在 Xamarin Forms 应用程序、下面的 Localizer 类和三个资源文件(默认 en-us、es、ar)中对本地化资源使用 ResX 方法。

enter image description here

当 Android 设备设置为西类牙语时,会显示相应的翻译字符串,但当设备设置为阿拉伯语时,会显示默认字符串。我在应用程序 list 中设置了属性 android:supportsRtl:"true",并且我的目标是 Android 4.2 或更高版本。

我错过了什么?

public class Localizer
{
    #region Constructors

    public Localizer()
    {
        RefreshLocale();
        this.Resources = new ResourceManager("MyApp.Resx.AppResources", typeof(Localizer).GetTypeInfo().Assembly);
    }

    #endregion Constructors

    #region Methods

    public void RefreshLocale()
    {
        this.Locale = DependencyService.Get<ILocale>().GetCurrent();
    }

    public string Localize(string key)
    {
        return this.Resources.GetString(key, new CultureInfo(this.Locale));
    }

    #endregion Methods

    #region Properties

    public string Locale { get; private set; }

    private ResourceManager Resources;

    #endregion Properties
}

最佳答案

哎呀,又被咬了。对于阿拉伯语资源文件 AppResources.ar.resx,Build Action 设置为 None。添加具有此文件类型的文件时,这似乎是 Xamarin Studio 的默认行为。将 Build Action 更改为 EmbeddedResource,重新构建和部署,一切都按预期进行。

关于android - 阿拉伯语字符串未显示在 Xamarin Forms 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29855717/

相关文章:

android - bogoMIPS 值正在改变

android - (TableLayout)findViewById( 空指针异常

c# - 在 Xamarin Studio 中删除未使用的 using 语句和排序 using 语句的最佳方法?

xamarin - 当我按下后退按钮时,导航栏色调颜色不会改变 Xamarin.iOS

android - 将 Activity 添加到后退堆栈时,如何使 Android AppCompat 工具栏中的文本居中?

java - Android JSON API解析

android - 销毁 Activity 时停止处理程序可运行的任务

android - 在 Android Studio 2.3 上创建项目时出错

grid - 如何在 Xamarin.Forms Xaml 中设置行/列定义?

ios - Xamarin 4 issue : iOS AOT problems which are not present in Xamarin 3. 怎么解决?