Xamarin.Forms:UWP 应用的本地化 [英] Xamarin.Forms: Localization of the UWP app

查看:32
本文介绍了Xamarin.Forms:UWP 应用的本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在 UWP 设备上运行我的应用程序,我会在 Output 窗口中收到以下警告:

If I run my app on an UWP device I get the following warning in the Output window:

MakePRI : 警告 0xdef00522: 找到语言en,de"的资源,但没有找到默认语言的资源:de-DE,en-US".更改默认语言或使用默认语言限定资源.http://go.microsoft.com/fwlink/?LinkId=231899

MakePRI : warning 0xdef00522: Resources found for language(s) 'en,de' but no resources found for default language(s): 'de-DE,en-US'. Change the default language or qualify resources with the default language. http://go.microsoft.com/fwlink/?LinkId=231899

不知道这是否相关,但我也明白

Don't know if this is related, but I also get

1>C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0AppxPackageMicrosoft.AppXPackage.Targets(2459,5):警告:APPX4001:未明确设置构建属性 AppxBundlePlatforms根据当前建筑结构计算.使用创建应用程序包"向导或编辑项目文件进行设置.

1>C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0AppxPackageMicrosoft.AppXPackage.Targets(2459,5): warning : APPX4001: Build property AppxBundlePlatforms is not explicitly set and is calculated based on currently building architecture. Use 'Create App Package' wizard or edit project file to set it.

此页面指出,我有特定于语言的资源,但我没有使用语言标签对其进行限定.我如何才能知道这些是哪些资源?

This page states, that I have language specific resources, which I haven't qualified with the language tag. How can I find out, which resources these are?

我在 Assets 文件夹中有图像,但它们是独立于语言的.此外,我已将 Package.appxmanifest 中的默认语言设置为 de-DE.如果我从警告中搜索语言缩写,我只能在 Debug 输出中找到 priconfig.xmlAppxManifest.xml文件夹.

I have images in the Assets folder, but they are language independent ones. Furthermore, I've set the default language in the Package.appxmanifest to de-DE. If I search for the language abbrevation from the warning, I can only find a priconfig.xml and AppxManifest.xml, both in the Debug output folder.

我应该怎么做才能消除这个警告?

What should I do to remove this warning?

如果我添加一个 AppResources.en-US.resx 文件,警告似乎消失了(目前我在 Package 中将 en-US 设置为默认语言.appxmanifest).另外,我有一个 AppResources.de.resxAppResources.resx 的文件(应该是 en).但是为什么 示例项目 不需要这样的文件,尽管应该有相同的设置?我错过了什么?

The warning seems to disappear if I add a AppResources.en-US.resx file (currently I have en-US set as default language in Package.appxmanifest). Additionally, I have a file for AppResources.de.resx and AppResources.resx (should be en). But why does the sample project doesn't need such a file, despite there should be the same settings? What I'm missing?

推荐答案

如果我添加 AppResources.en-US.resx 文件,警告似乎消失了(目前我在 Package.appxmanifest 中将 en-US 设置为默认语言).此外,我有一个 AppResources.de.resx 和 AppResources.resx 文件(应该是 en).但是为什么示例项目不需要这样的文件,尽管应该有相同的设置?我错过了什么?

The warning seems to disappear if I add a AppResources.en-US.resx file (currently I have en-US set as default language in Package.appxmanifest). Additionally, I have a file for AppResources.de.resx and AppResources.resx (should be en). But why does the sample project doesn't need such a file, despite there should be the same settings? What I'm missing?

如您所说,AppResources.resx 是 en.您可以展开 Portable Class Library (PCL) 项目中的 Properties 节点并双击 AssemblyInfo.cs 文件.将以下行添加到文件中以将中性资源汇编语言设置为英语:

As you said, the AppResources.resx is en. And you could expand the Properties node in the Portable Class Library (PCL) project and double-click on the AssemblyInfo.cs file. Add the following line to the file to set the neutral resources assembly language to English:

[assembly: NeutralResourcesLanguage("en")]

这会通知资源管理器应用的默认区域性,从而确保当应用在一种英语语言环境中运行时,将显示在语言中性 RESX 文件 (AppResources.resx) 中定义的字符串.

This informs the resource manager of the app's default culture, therefore ensuring that the strings defined in the language neutral RESX file (AppResources.resx) will be displayed when the app is running in one the English locales.

您在Package.appxmanifest中设置了en-US为默认语言,但是没有对应的文件.所以它会抛出警告.

You have set en-US as default language in Package.appxmanifest, However, there is no such file corresponding to it. So it will throw warning.

示例项目的默认语言是en-US,没有对应的文件.它也在我身边发出同样的警告.如果将默认语言修改为 en,警告就会消失.因为它在 AssemblyInfo.cs 文件中设置了 AppResources.resxen .

The default language of the sample project is en-US, and there is no such file corresponding to it. It also throw the same warning in my side. if you modify the default language to en, the warning disappear. Because it has set AppResources.resx as en in AssemblyInfo.cs file.

更多的你可以参考AssemblyInfo支持的语言.

这篇关于Xamarin.Forms:UWP 应用的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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