2017-03-05 28 views
0

我有一個本地化的WPF應用程序。我的WPF應用程序啓動時,我的WPF應用程序下面的代碼行不是在閱讀CultureInfo.CurrentCulture(hi-IN),而是從ControlPanel - > Region - > Formats設置格式爲印地文(印度)而是使用en-US。Default Resource.resx文件未使用

Application.Current.MainWindow = new MainWindow(); 
Application.Current.MainWindow.Show(); 

因此,我的WPF應用程序未使用來自Resources.resx文件的問候消息。相反,它是使用來自Resources.en.resx中的問候語消息

我在CultureInfo.CurrentCulture中獲得了適當的值。

任何想法爲什麼上面的代碼行不選擇適當的值?

+1

非常規的索賠需要非常的證據,我沒有看到任何。就像.NET區分CurrentCulture和CurrentUICulture一樣,操作系統也是如此。所以你可能已經改變了系統區域,但不是顯示語言。或者您可能忘記註銷+登錄以使更改生效。請在superuser.com上尋求幫助正確配置 –

回答

1

ControlPanel-> Region-> Formats設置不適用於.resx文件。它在ControlPanel-> Region-> Language中,指定默認語言。

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

或者你可以在你的App類(App.xaml.cs)指定資源的默認語言:

public partial class App : Application 
{ 
    protected override void OnStartup(StartupEventArgs e) 
    { 
     base.OnStartup(e); 

     Resources.Culture = System.Threading.Thread.CurrentThread.CurrentCulture; 
    } 
} 

請參考以下鏈接瞭解更多信息:https://social.msdn.microsoft.com/Forums/vstudio/en-US/6bfb8d13-3a86-4c10-a632-bb20c99d0535/localization-in-wpf-using-resx-files-for-different-languages?forum=wpf

相關問題