By default Windows Store UWP apps install only resources specific for the target machine. For instance if the app is localized into 5 different languages and user has machine in en-US, only en-US resources are installed.
The problem is if I want to have in my app on-demand language switching. Even thought I published app with fr-FR resources, I cannot switch to fr-FR because this language pack is not installed.
Is there a way or setting to force all resources to download when the app is installed from Windows Store?
Note one way, how to solve this is not package the app as appxbundle, but once the app is published as appxbundle, it's not possible to go back to non-appxbundle format.
Edit, the accepted solution below worked, I just added this config to my .csproj file and now it downloads all resource files during the installation:
<AppxBundleAutoResourcePackageQualifiers>Scale|DXFeatureLevel</AppxBundleAutoResourcePackageQualifiers>
<AppxDefaultResourceQualifiers>Language=cs-CZ;de-DE;en-US;es-ES;fr-FR;it-IT;pt-PT;ru-RU</AppxDefaultResourceQualifiers>
All apps ARE NOT necessarily UWP apps. Windows 8.1 apps do run on Windows 10, just not the other way around. Not every company or indie developer has updated their apps to support UWP.
If you are distributing your app via the Microsoft Store, Visual Studio can associate your package with the Store. To do this, right-click your project name in Solution Explorer and choose Publish->Associate App with the Store (before Visual Studio 2019 version 16.3, the Publish menu is named Store).
As you've known, by default UWP apps will be installed in C:\Program Files\WindowsApps . you can the default install location in Settings → System → Storage → Change where new content is saved. You can choose one drive from the drop-down menu under "New apps will save to" and then click Apply.
By default Windows Store UWP apps install only resources specific for the target machine. For instance if the app is localized into 5 different languages and user has machine in en-US, only en-US resources are installed.
You use the ms-resource URI (Uniform Resource Identifier) scheme to do this. Repeat this process for each string in your manifest that you want to localize. For example, your app's Short name (which you can configure to appear on your app's tile on Start).
The most essential property of a localizable app is that its executable code has been cleanly separated from its localizable resources. So, you should determine which of your app's resources need to be localized.
Open your app package manifest source file (the Package.appxmanifest file), in which by default your app's Display name is expressed as a string literal. To make a localizable version of this string, open Resources.resw and add a new string resource with the name "AppDisplayName" and the value "Adventure Works Cycles".
Note one way, how to solve this is not package the app as appxbundle, but once the app is published as appxbundle, it's not possible to go back to non-appxbundle format.
If you need to keep the appxbundle, but still want to keep all the language resource installed. You can include the resources by adding a configuration file to your app package or modify your project file directly.
In this way, users can change language preferences offline and their devices can switch to the best resources for the new settings.
For detailed steps, please follow Ensure that resources are installed on a device regardless of whether a device requires them, which targets on Windows Store 8.1 app, but it works to UWP app as well. Also, you can check @Amy Peng's answer in this thread on MSDN forum .
I think the system will not allow you to force this without cheating the conventions.
As a workaround, you could name the resource files in such manner that the system itself doesn't recognize it is dealing with localized resources - instead of having Resources.en-US.resw
, Resources.fr-FR.resw
, etc., you could name them Resources_enUS.resw
, Resources_frFR.resw
for example.
Then you could have a LocalizationService
class, that would accept the culture tag as constructor parameter and manually load the resources for that specific culture:
public class LocalizationService
{
private readonly ResourceLoader _loader = null;
public LocalizationService(string culture)
{
culture = culture.Replace("-", "");
_loader = ResourceLoader.GetForCurrentView($"Resources_{culture}");
}
}
Then you could just create the LocalizationService
with the requested culture
var localizer = new LocalizationService( "fr-FR" )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With