I'm developing application which requires for me to handle multiculture and resources in Windows Phone 8.1.
Currently it loads en language if my phone language is set to english, if I change it to french or whatever it also works. What i would like to do is for a user to be able to change the language in the app while not changing the language in the phone. I would like to have a settings page when user can pick language from a list of possibilities. Save it in some storage settings and after application start to load appropriate resources.
What I can't figure out is how to load specific resources based on some settings in the storage.
Use IsolatedStorage to store the user selected language string.
When the app is loaded you can change the language to that selected by user using the
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride
Property.
Let me give you some details. Create a class as LacalizedStrings.cs
in your project. And let's put that the resource file name is AppResources
public class LocalizedStrings
{
private static AppResources _localizedResources = new AppResources();
public AppResources LocalizedResources { get { return _localizedResources; } }
}
in your AppResources
put one key as ResourceLanguage
and value as en-US
.
Now this value you can save in IsolatedStorage
and the time of
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
or
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
you can check this value from IsolatedStorage
and use it.
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.