Tai Nguyen
Tai Nguyen

Reputation: 956

Windows phone 8.1 How to load Resources File RESW

I would like to know if its possible to load a resources file?

I mean. I have currently 2 folders which is fr-FR end en-US.

In each folder, I have a Resources.resw. These 2 files work when I change the language in the setting of the phone. If the phone is in FR or US, It will load the right Resources.resw.

But I would like to know if I can change it inside the application? Load the right file when user will select fr/en.

enter image description here

Thank you for your help.

Upvotes: 0

Views: 107

Answers (1)

Amy Peng - MSFT
Amy Peng - MSFT

Reputation: 1902

We can use the ApplicationLanguages.PrimaryLanguageOverride to change the language during runtime without restart the phone and application:

   private async void ChangeLagButton_Click(object sender, RoutedEventArgs e)
    {
        var culture = new System.Globalization.CultureInfo("fr-FR");
        Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
        Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
        Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
        await Task.Delay(100);
        //To refresh the UI without restart the phone
        this.Frame.Navigate(this.GetType());          
    }

Upvotes: 2

Related Questions