問題描述
我有 2 種語(yǔ)言的資源文件,我的應(yīng)用程序已經(jīng)讀取其中一種語(yǔ)言的值.我希望能夠在 C# 中更改我的應(yīng)用程序的語(yǔ)言(使用其他資源文件),而不是在設(shè)置中更改整個(gè)手機(jī)的語(yǔ)言.
I have my Resource files with 2 languages and my app already reads the values of one of them. I would like to be able to change the language of my app (use the other resource file) in C# instead of changing the language of the whole phone in Settings.
這可能嗎?如果有,怎么做?
Is this possible? If so, how?
推薦答案
在App.xaml.cs
中,在InitializePhoneApplication
方法中:
private void InitializePhoneApplication()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
.......
}
限制是需要在app初始化中,所以如果用戶改變語(yǔ)言,需要重啟才能生效.
The limitation is that it needs to be in the app initialization, so if the user changes the language, a restart will be required for it to take effect.
這篇關(guān)于如何在 Windows Phone 上更改 C# 中的本地化?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!