0

I have a WPF application which is localized.

When I set Format to Hindi(India) from ControlPanel -> Region -> Formats, Following lines of code in my WPF application at the beginning of launching of my WPF Application is not reading CultureInfo.CurrentCulture(hi-IN) instead it uses en-US.

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

Because of this, My WPF Application is not using greeting message from Resources.resx file. Instead, it is use greeting message from in Resources.en.resx

I am getting proper value in CultureInfo.CurrentCulture.

Any idea why above lines of code are not picking proper value?

mm8
  • 163,881
  • 10
  • 57
  • 88
user1833852
  • 51
  • 2
  • 10
  • 1
    Extraordinary claims require extraordinary evidence, I don't see any. Just like .NET distinguishes between CurrentCulture and CurrentUICulture, so does the operating system. So you might have changed the system locale but not the display language. Or you might have forgotten to logout+login to make the change effective. Ask for help configuring this correctly at superuser.com – Hans Passant Mar 05 '17 at 15:18

1 Answers1

1

The ControlPanel->Region->Formats setting doesn't apply to .resx files. It is in ControlPanel->Region->Language that you specify the default language.

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

Alternatively you could specify the default language of your resources in your App class (App.xaml.cs):

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

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

Please refer to the following link for more information: 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.

Community
  • 1
  • 1
mm8
  • 163,881
  • 10
  • 57
  • 88