如何在Windows Phone应用程序的代码中设置UI语言? [英] How to set UI language in code for Windows Phone application?

查看:77
本文介绍了如何在Windows Phone应用程序的代码中设置UI语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我的应用程序不支持区域性es-MX,因此,当这是电话上的当前设置时,我想将区域性设置为es-ES.是否可以在Windows Phone中执行此操作?

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?

推荐答案

这绝对有可能! 有关文化及其标识符,请参见此列表

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

因此,例如在App.xaml.cs构造函数中,您可以访问Thread.CurrentThread.CurrentCulture以确定应用程序在其中运行的实际区域性.现在,如果您想强制UI使用其他区域性,则可以通过以下方法实现设置CurrentUICulture.例如:

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

这篇关于如何在Windows Phone应用程序的代码中设置UI语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆