Windows Phone 8.1 manually modifies the resource file in the code behind

I am developing an application that requires me to handle multiculturalism and resources in Windows Phone 8.1.

It is currently downloading the language if my phone language is set to English, if I change it to French or whatever it works. I would like the user to be able to change the language in the application without changing the language in the phone. I would like to have a settings page when the user can select a language from the list of features. Save it in some storage settings and after the application starts loading the corresponding resources.

I cannot figure out how to load certain resources based on some settings in the repository.

+4
source share
2 answers

Use IsolatedStorage to save the user selected string of language.

When the application is downloaded, you can change the language to the user selected using

Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride

Property.

0
source

Let me give you some details. Create a class like LacalizedStrings.csin your project. And let this be the name of the resource fileAppResources

public class LocalizedStrings
    {
        private static AppResources _localizedResources = new AppResources();
        public AppResources LocalizedResources { get { return _localizedResources; } }
    }

in AppResourcesenter one key as ResourceLanguagewell as value en-US.

Now this value can be saved in IsolatedStorageand time

private void Application_Launching(object sender, LaunchingEventArgs e)
{
}

or

private void Application_Activated(object sender, ActivatedEventArgs e)
{
}

You can check this value with IsolatedStorageand use it.

Hope this helps.

0
source

All Articles