Xamarin.Forms:UWP应用程序的本地化 [英] Xamarin.Forms: Localization of the UWP app
问题描述
如果我在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
不知道这是否相关,但我也知道
Don't know if this is related, but I also get
1> C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v14.0 \ AppxPackage \ Microsoft.AppXPackage.Targets(2459,5):警告:APPX4001:未明确设置构建属性AppxBundlePlatforms并且它是根据当前建筑物的架构进行计算.使用创建应用包"向导或编辑项目文件进行设置.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.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.xml
和AppxManifest.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.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.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.然后,您可以在可移植类库(PCL)项目中展开属性"节点,然后双击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
,警告将消失.因为它已将AppResources.resx
设置为AssemblyInfo.cs
文件中的en
.
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
a>,受支持的语言.
这篇关于Xamarin.Forms:UWP应用程序的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!