How to get the Windows Phone system language from code?

隐身守侯 提交于 2020-01-02 07:09:11

问题


Solution: Use CultureInfo.CurrentUICulture

User can change the system language of Windows Phone at: Settings > language+region > Phone language

How can I get the selected language (Phone language) from C# code?

Below is my phone settings:

Here is my code snippet:

System.Diagnostics.Debug.WriteLine(
    "*************************************   CultureInfo.CurrentCulture.Name = " + CultureInfo.CurrentCulture.ToString() + ", "  +
    "CultureInfo.CurrentCulture.CompareInfo = " + CultureInfo.CurrentCulture.CompareInfo + ", " +
    "CultureInfo.CurrentCulture.DisplayName = " + CultureInfo.CurrentCulture.DisplayName + ", " +
    "CultureInfo.CurrentCulture.EnglishName = " + CultureInfo.CurrentCulture.EnglishName + ", " +
    "CultureInfo.CurrentCulture.Name = " + CultureInfo.CurrentCulture.Name + ", " +
    "CultureInfo.CurrentCulture.NativeName = " + CultureInfo.CurrentCulture.NativeName + ", " +
    "CultureInfo.CurrentCulture.TextInfo = " + CultureInfo.CurrentCulture.TextInfo
);

Here is the output:

CultureInfo.CurrentCulture.Name = zh-HK,
CultureInfo.CurrentCulture.CompareInfo = CompareInfo - zh-HK,
CultureInfo.CurrentCulture.DisplayName = Chinese (Traditional, Hong
Kong SAR), CultureInfo.CurrentCulture.EnglishName = Chinese
(Traditional, Hong Kong SAR), CultureInfo.CurrentCulture.Name = zh-HK,
CultureInfo.CurrentCulture.NativeName = 中文(香港特別行政區),
CultureInfo.CurrentCulture.TextInfo = TextInfo - zh-HK

I cannot find the 'Phone Language'


回答1:


Use System.Threading.Thread.CurrentThread.CurrentCulture. It should correctly reflect the phone language.




回答2:


you can check my answer, this will help you to change the language at runtime: https://stackoverflow.com/a/17131401/2467917



来源:https://stackoverflow.com/questions/14518411/how-to-get-the-windows-phone-system-language-from-code

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