How to always install all localized resources in the Windows Store UWP app?

By default, Windows Store UWP applications install only resources specific to the target machine . For example, if the application is localized in 5 different languages, and the user has a machine in en-US, only resources in the USA will be installed.

The problem is that I want to have on-demand language switching in my application. Even I thought I published an application with fr-FR resources, I can't switch to fr-FR because this language pack is not installed.

Is there a way or option to force download all resources when the application is installed from the Windows Store?

Please note that one way: do not package the application as appxbundle, but once the application is published as appxbundle, it is impossible to return to the format without appxbundle.

Edit , the decision made below works, I just added this configuration to my .csproj file, and now it downloads all resource files during installation:

<AppxBundleAutoResourcePackageQualifiers>Scale|DXFeatureLevel</AppxBundleAutoResourcePackageQualifiers> <AppxDefaultResourceQualifiers>Language=cs-CZ;de-DE;en-US;es-ES;fr-FR;it-IT;pt-PT;ru-RU</AppxDefaultResourceQualifiers> 
+6
source share
3 answers

Pay attention to one of the ways: how to solve the problem, this is not an app application like appxbundle, but after the application is published as appxbundle, it is impossible to return to a format other than appxbundle.

If you need to save appxbundle, but still want to save the entire language resource. You can enable resources by adding a configuration file to your application package or directly modify the project file.

Thus, users can change the language settings offline, and their devices can switch to the best resources for new settings.

For detailed instructions, see Make sure resources are installed on the device, regardless of whether they need a device that targets Windows Store 8.1, but it also works with the UWP application. Alternatively, you can check @Amy Peng's answer in this thread on the MSDN forum.

+4
source

I think that the system will not allow you to force it without deception of agreements.

As a workaround, you can name the resource files in such a way that the system itself does not recognize it , it deals with localized resources - instead of Resources.en-US.resw , Resources.fr-FR.resw , etc., you can name their Resources_enUS.resw , Resources_frFR.resw , for example.

Then you can have a LocalizationService class that takes a culture tag as a constructor parameter and manually loads resources for that particular culture:

 public class LocalizationService { private readonly ResourceLoader _loader = null; public LocalizationService(string culture) { culture = culture.Replace("-", ""); _loader = ResourceLoader.GetForCurrentView($"Resources_{culture}"); } } 

Then you can simply create a LocalizationService with the requested culture

 var localizer = new LocalizationService( "fr-FR" ) 
+1
source
0
source

Source: https://habr.com/ru/post/1012870/


All Articles