Implement multi-language in Windows Forms App

“And the App must be in Dutch!” One of my customers only wants to work with the app when all text is presented in Dutch. This blog describes how you can implement multi-language in your Windows Forms App.

Requirements

  • Visual Studio
  • Windows Forms Application

Quick steps

  1. Edit a form and set the form’s Localizable property to true.
  2. Set the form’s Language property to Dutch (Nederlands).
    1. Change all UI text accordingly to the selected language.
    1. Save All changes
  3. Visual Studio will generate the resource files for you
Visual Studio, Project Multilingual, Form resource files (one per language).

After translating all UI texts, the App must be restarted to show the selected language.

public Form1()
{
  Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-NL");
  InitializeComponent();
}

Text build up from code can be retrieved by the using the resource manager. In the following example the “MsgFileCount” is a new resource string that is added to the resource of the project.

// C# code example
ResourceManager rm = new ResourceManager(typeof(Form1));
MessageBox.Show(string.Format(rm.GetString("MsgFileCount") + "{0}", 0));
rm = null;