UWP:语言的资源文件未正确部署 [英] UWP: Resource file for languages is not deployed correctly

查看:15
本文介绍了UWP:语言的资源文件未正确部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Universal-Windows-App 有问题:我让用户可以选择更改应用程序的语言.

为此,我为每种语言创建了一个Ressources.resw"文件,我的 XAML 代码通过 x:UID= 部分引用了资源.通过

我怎样才能避免这种情况?

解决方案

但是,如果我通过 Store->Create App Packages 部署应用程序,然后尝试在(不同的)Windows-10 机器上旁加载应用程序,则语言更改无法正确反映.
但是:如果用户安装了相应的 Windows-Language-Pack,则该应用程序运行正常.我的猜测是,Windows 将检查它将与已安装的语言资源文件一起部署系统语言:

如果我将生成应用程序包"设置为总是"如果需要",我可以重现此行为,这样,只有当用户安装了相应的 Windows-Language-Pack 时,应用程序才能正常工作.

这是因为如果我们将生成应用程序包"设置为始终"如果需要">,它将创建应用程序包.这意味着它将把您的应用程序分成不同的部分以优化下载.只会下载与设备相关的部分.例如,如果有不同分辨率的资产,它只会下载适合设备的资产.语言也一样,只会下载与设备语言相关的资源文件.因此,如果您尝试更改语言,它仍然会失败,但仍会退回到相同的基本语言,因为其他语言尚未安装.因此,如果您没有安装相应的 Windows-Language-Pack,应用将不会显示指向资源文件的该属性的相关语言.

更多信息请尝试参考

I have a problem with my Universal-Windows-App: I'm giving the user the option to change the language of the app.

For this propose I've created for each language a "Ressources.resw" file and my XAML-code referes via the x:UID= part to the resources. The language is changed via primaryLanguageOverride This is working fine in my environment. However, if I deploy the app via Store->Create App Packages and then try to sideload the app on (different) Windows-10 machines the language change is not reflected correctly. For example the date-format is changing properly but the properties that are pointing to the resources file are not changing correctly.

But: If the user has the corresponding Windows-Language-Pack installed, the app is working fine. My guess is, that Windows will check which language-resource file it will deploy with the installed languages on the system:

How can I avoid this?

解决方案

However, if I deploy the app via Store->Create App Packages and then try to sideload the app on (different) Windows-10 machines the language change is not reflected correctly.
But: If the user has the corresponding Windows-Language-Pack installed, the app is working fine. My guess is, that Windows will check which language-resource file it will deploy with the installed languages on the system:

I can reproduce this behavior if I have set the "Generate App bundle" as "always" or "if needed", in this way as you said only if the user has the corresponding Windows-Language-Pack installed, then the app will work fine.

The reason for that it is because that if we have set the "Generate App bundle" as "always" or "if needed", it will create the app bundle. It means that it will cut your application into different parts to optimize the download. Only the parts that are relevant for the devices will be downloaded. For example, if there are the assets in different resolution, it will only download the ones that are suitable for the device. Same thing for languages, it will only download the resources file relevant to the language of the device. So if you try to change language, it will fail still fall back on the same base language, because others are not installed. So if you do not have the corresponding Windows-Language-Pack installed, the app will do not show the related language for that property which are pointing to the resources file.

For more information, please try to refer to this blog.

How can I avoid this?

If you want to avoid this, the workaround is to set the "Generate App bundle" as "never" as following when creating the app package and I have tested in my side, it works fine:

这篇关于UWP:语言的资源文件未正确部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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