سؤال

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'

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top