Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

c# - UWP: Resource file for languages is not deployed correctly

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:

enter image description here

How can I avoid this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...