2013-01-25 33 views
4

解決方案: 設置>語言+區域>手機語言如何從代碼獲取Windows Phone系統語言?

我怎樣才能獲得所選擇的語言(手機語言): 使用CultureInfo.CurrentUICulture

用戶可以更改的Windows Phone系統語言來自C#代碼?

下面是我的手機設置:

這裏是我的代碼片段:

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

這裏是輸出:

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 

我無法找到「電話語言'

+0

可能重複(HTTP:/ /stackoverflow.com/questions/8405128/howto-find-our-the-current-language-which-the-user-has-selected-on-his-wp7) –

+0

嗨,情緒,我已經更新了我的問題 –

回答

6

使用System.Threading.Thread.CurrentThread.CurrentCulture。它應該正確地反映手機語言。

+0

謝謝克勞斯,似乎是System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo是我正在尋找。 –

+2

剛剛發現System.Threading.Thread.CurrentThread.CurrentCulture不適用於WP8。解決方法是使用CultureInfo.CurrentUICulture代替。 –

+0

它工作正常WP8 ... –

相關問題