How to set UI language in code for Windows Phone a

2019-07-27 14:23发布

问题:

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");
}