“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
- Edit a form and set the form’s Localizable property to true.
- Set the form’s Language property to Dutch (Nederlands).
- Change all UI text accordingly to the selected language.
- Save All changes
- Visual Studio will generate the resource files for you
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;