使用xamarin的移动跨平台的本地化和仅限iOS的问题

Sof*_*San 15 c# localization xamarin.ios xamarin.android portable-class-library

我在Xamarin有一个针对Android,iOS和Windows手机的项目.我用核心(PCL库)在不同平台之间共享公共代码.我在我的核心库中添加了资源文件(.net资源).Resx,并在我的一个ViewModel中读取了我在以下代码片段中使用的特定于文化的字符串:

public string GetString() 
{  
    // CommonResources is the name of my resource file   
    ResourceManager resManager = new ResourceManager(typeof(CommonResources));   
    return resManager.GetString("LoginLabel",CultureInfo.CurrentCulture); 
}
Run Code Online (Sandbox Code Playgroud)

"LoginLabel"是我的资源键,其值为"登录"(英文)和荷兰语中的"inloggen".

我在我的PCL项目中为英语和荷兰语创建了两个资源文件CommonResources. CommonResources.resx
CommonResources.nl-NL.resx

在android,iOS和windows手机中,我将文化设置如下:

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("nl-NL");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("nl-NL");
Run Code Online (Sandbox Code Playgroud)

这适用于Android和Windows手机.

但对iOS来说它不起作用.它总是从英文文件返回资源字符串.文化已正确设置,并以调试模式显示.但不知何故,它无法从荷兰资源加载资源字符串.

所以问题是,可以使用PCL为所有平台本地化字符串(.Net方式)吗?有谁有任何想法?提前致谢.

Tre*_*ert 2

为了对我们的 Xamarin 项目进行本地化,我使用了 Microsoft 的多语言应用程序工具包(详细信息请参见此处)和 T4 模板,将工具包的输出转换为适用于 Android 和 iOS 的可用格式。

教程对该过程进行了精彩的概述,并且基于代码项目。