阿拉伯语字符串没有显示在Xamarin窗体应用程序 [英] Arabic strings not displaying in Xamarin Forms app

查看:227
本文介绍了阿拉伯语字符串没有显示在Xamarin窗体应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的方法的ResX在一个Xamarin本地化资源窗体应用程序,下面的定位器类,三个资源文件(默认EN-US,ES,AR)。

当Android设备设置为语言西班牙语,显示相应的翻译字符串,但在设备设置为阿拉伯语,显示默认字符串。我已经设置属性android:supportsRtl:真在应用清单,并针对我的Andr​​oid 4.2或更高版本。

我是什么失踪?

 公共类定位器
{
    #区域构造    公共定位器()
    {
        RefreshLocale();
        this.Resources =新的ResourceManager(MyApp.Resx.Ap presources的typeof(本地化).GetTypeInfo()汇编);
    }    #endregion构造    #区域方法    公共无效RefreshLocale()
    {
        this.Locale = DependencyService.Get&所述; ILocale方式>()GetCurrent();
    }    公共字符串本地化(字符串键)
    {
        返回this.Resources.GetString(关键,新的CultureInfo(this.Locale));
    }    #endregion方法    #区域属性    公共字符串区域设置{搞定;私人集; }    私人ResourceManager的资源;    #endregion属性
}


解决方案

呵呵咄,再次咬伤。生成操作设置为无,阿拉伯语资源文件鸭presources.ar.resx。这似乎与此文件类型添加文件时要默认Xamarin Studio的行为。改变了生成操作EmbeddedResource,改建和部署,一切工作正常。

I am using the ResX approach for localized resources in a Xamarin Forms app, the Localizer class below, and three resource files (default en-us, es, ar).

When the Android device setting is language Spanish, the appropriate translated string is displayed, but when the device setting is Arabic, the default string is displayed. I have set the attribute android:supportsRtl:"true" in app manifest, and am targeting Android 4.2 or higher.

What am I missing?

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
}

解决方案

Oh duh, bitten again. The Build Action was set to None for the Arabic resource file AppResources.ar.resx. This appears to be default Xamarin Studio behavior when adding files with this filetype. Changed the Build Action to EmbeddedResource, rebuilt and deployed, and everything works as expected.

这篇关于阿拉伯语字符串没有显示在Xamarin窗体应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆