How to set UI language in code for Windows Phone application?

别等时光非礼了梦想. 提交于 2019-12-11 10:51:07

问题


Let's say my application doesn't support culture es-MX so when this is the current setting on the phone I'd like to set the culture to es-ES. Is this possible to do in Windows Phone and if so how?


回答1:


This is definitely possible! See this list for cultures and their identifiers

So for example in the App.xaml.cs constructor you could access Thread.CurrentThread.CurrentCulture to determine the actual culture the app is running in. Now if you want to force the UI to use another culture you can do that by setting the CurrentUICulture. For example:

if (Thread.CurrentThread.CurrentCulture.Name.Equals("es-MX"))
{
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-ES");
}


来源:https://stackoverflow.com/questions/19098643/how-to-set-ui-language-in-code-for-windows-phone-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!