How to locate a WinRT application?

A .resw file must be added for each language of the application.

Original illustration unavailable: resource

As follows (one file per language):

Original illustration unavailable: location

Complete list of culture codes here.

In this file Name” must be matched to translations:

Original illustration unavailable: language

For each language you must recreate the same keys.

If you do not create a key in a language, the default language will be used automatically by the application.

I highly recommend using the visual studio extension ResX Manager This will allow you to edit all the resource files in one window. Toss)

Original illustration unavailable: ResXManager

I also recommend another extension to generate a class like resx files: You can download it here.

Where is the default language of the application configured?

We can set that in the Package.appxmanifest.

Original illustration unavailable: here

What language will be used when a user launches my app?

The language used will be that of the device if the app is available in this one.

Otherwise the app will use the default language of the application.

How does the store detect the languages of my app?

The store analyses your packages and automatically detects the languages managed by the application.

Be careful If your resource files are in a PCL library, the detection will not work properly.

In which case automatic detection must be disabled in Package.appxmanifest and the languages managed by the application specified.

Change this knot below:


<Resources>
    <Resource Language="x-generate" />
</Resources>

For example:


<Resources>
    <Resource Language="fr-FR" />
    <Resource Language="it-IT" />
    <Resource Language="en-US" />
    <Resource Language="ro-RO" />
    <Resource Language="de-DE" />
</Resources>

How do you access a localized resource?

In C#:

If the resources are in the main executable:


var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
var txt = resourceLoader.GetString(key);

Otherwise:


var resourceLoader = ResourceLoader.GetForViewIndependentUse("NOMDELADLL/Resources");
var txt = resourceLoader.GetString(key);

If you want to stay heavily typed an extension allows to generate a class for your resource files is available hereThank you . Samuel is)

In XAML:

The key to the resource will be: HelloTextBlock.Text


<TextBlock x:Uid="HelloTextBlock" Text="" />

Can I force the language used by the application?

Yes, at the start, as follows:


void DefineLangageForApplication()
{
     Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fr-FR";
}

On Windows 8 only:

You can also enter the app but you'll need to re-display the controls to have the screen located.


Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = _settings.GetLanguageInStringValue();
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();

In Windows Phone:

The application will need to be restarted to take into account the new language:


Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = _settings.GetLanguageInStringValue();
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
await new Windows.UI.Popups.MessageDialog("Attention l'app va reboooooot").ShowAsync();
Application.Current.Exit();

What does the compiler do when you compile an app with multiple locations?

For each resource file the compiler will generate a different appx.

Other than for the default language that is included with your app's binary.

Original illustration unavailable: Localisation

You'll notice that the compiler works the same way for images scale 100/140/240;

So when a user downloads your app, they download:

application (so with the default language)

– the resources for the languages he has installed on his machine (if for example you have installed French and Italian he will download both packages).

Be careful When you debug your virtual machine, when Visual Studio deploys your apps, it deploys all of them the resources.

So if you make a language selector, once you apply it to the store, the language change won't work if the language isn't installed on your OS, so even with visual studio deploying the apps, everything will work fine.

If anyone has a solution to be able to pack all the resources as for the default language I'm a buyer. 🙂