Search code examples
vb.netwinformslocalizationglobalization

Basic localization (neutral language)


I have a WinForms app in .Net4 where I'm having problems implementing multiple languages.

Disclaimer: I have searched and found many questions about globalization/localization, but the vast majority are trying to do something unusual, or custom. I'm having trouble with the basic out of the box stuff. I have read the documentation, but am still having problems.

I have a WinForms app, the default language is English. I need to display it in French on french PCs, it could be either fr-FR or fr-CA, so I when I set the form to localizable:=True, I changed the language to "French" and updated the labels, buttons, and other form controls. That part, I Think I've done correctly.

Form message boxes, I put all my strings into the resources file (by clicking my project, then the resources tab). I replaced the strings in code with references to my.ressource.{ressourcename}

I then added a new Resources.fr.resx in the myproject folder and translated all the strings it contained.

I tried to test this by adding the following line to the new() constructor of my startup form.

Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr")

I also tried:

Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-CA")

The application still loads in English, even the form controls which are set to the neutral language 'French'.

In summary, there are 4 questions:

  1. Am I going about this correctly?
  2. Have I created the French resource file correctly?
  3. Should the Resources.fr.resx file be in the My Project folder (along side the default Resources.resx, or should it be in the root? Or alternatively should I be using a new file like MessageResources.resx and MessageResources.fr.resx and place both of those in the root?
  4. How do I force the entire application to use French instead of default language?

Solution

  • Thanks for all your help. As it turns out, my localization settings were all correct. The problem was that I was using MSBuild.ILMerge.Task (NuGet package) to merge my assemblies into a single EXE. It seems that was affecting the localized resources.

    Disabling that merge solved the problem. I'll start a new question more specific to how to handle that particular scenario.