可移植类库和resx本地化 [英] Portable class library and resx localization

查看:100
本文介绍了可移植类库和resx本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可移植类库,其中有包含本地化字符串的resx文件(Resources.resx,Resources.en.resx,Resources.de.resx).然后,我以这种方式在PCL LocalizationViewModel中使用这些资源:

I have Portable class library, where I have resx files containing localization strings (Resources.resx, Resources.en.resx, Resources.de.resx ). Then I use this resources in the PCL LocalizationViewModel in this way :

public string SettingsLogin
{
        get { return Resources.Settings_Login; }
}

语言切换代码如下:

在PCL中

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(lang);
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(lang);
Resources.Culture = new CultureInfo(lang);

在Win8.1应用程序中

In Win8.1 app

Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = lang;

LocalizationViewModel中的字符串在Win8.1应用程序中使用,并且效果很好,并且在运行时也可以更改语言.

Strings from LocalizationViewModel are consumed in Win8.1 application and it works pretty good, change of the language in the runtime as well.

创建应用程序包并安装应用程序时出现问题.当我运行已安装的应用程序时,语言切换不起作用.

在resx文件中,我使用嵌入式资源构建操作,并尝试了构建操作和复制到输出目录"设置的所有组合.

In resx files, I use embedded resource build action and I tried all combination of the build action and the "copy to output directory" setting.

类似的项目,您可以在

Similar project you can find in this article

您知道可能是什么问题吗?

Do you have any idea what can be the problem?

推荐答案

查看下面链接的图像. 我遇到了同样的问题,将设置更改为从不",它可以解决问题.

See the image linked below. I ran into the same problem, change the setting to Never and it fixes the problem.

这篇关于可移植类库和resx本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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