Best practice to make a multi language application in C#/WinForms?

pbean picture pbean · Sep 23, 2008 · Viewed 97.8k times · Source

I've been looking into making applications suitable for multiple languages in C# since I need to work on a small project where this is the case. I have found basically two ways to do this:

Set a form's Localizable property to true, set the Language property, fill all the labels and such, and you're 'done'. The major drawback I see in this is: how to make other stuff which is not part of a form ready for multiple languages (e.g. pop-up windows, log files or windows, etc).

Create a resource file, for example 'Lang.en-us.resx' and one for every language, for example 'Lang.nl-nl.resx' and fill it up with Strings. The IDE seems to generate a class for me automatically, so in the code I can just use Lang.SomeText. The biggest drawback I see in this is: for every form I need to set all the labels and other captions myself in the code (and it doesn't seem data binding works with these resources).

I'm sure, however, that there are other methods to do this as well.

So, what is the best practice? What's the easiest for small applications (a few forms, database connection etc) and what scales best for larger applications?

Answer

ThatBloke picture ThatBloke · Sep 23, 2008

I have always used resource files for multi-language applications.
The are many articles on the web explaining how to use them.

I have used two different ways:

  • A resource file per form
  • A global resource file

The resource file / form, is easier to implement, you only need to enter the values in the resource file, but I find this approach harder to maintain, since the labels are dispersed throughout the application.

The global resource file allows you to centralise all the labels (images etc.) in one file (per language), but it means manually setting the labels in the form load. This file can also be used for error messages etc.

A question of taste...

One last point, I write programs in English and French, I use "en" and "fr" and not "en-US" and "fr-FR". Do not complicate things, the different dilelects of English (American, English, Australian etc) have few enough differences to use only one (the same goes for French).