You may use resource files or configure xml to implement multiple languages.
I didn't have time to study too much. I learned how to use resource files.
In. net2.0, m $ provides us with a simple and convenient method to use resource files.
1. Create a Winform application, create a Form named Form1, and add a menu button.
2. Set the Localizable attribute of Form1 to true. After this attribute is set,. net will generate different resource files for the application based on different languages.
3. Set the text of each control (in the default system language)
4. Change the Language attribute of Form1 to another Language to be supported. In this example, we use English
5. Reset the text of each control.
Note: In this case,. net will generate another resource file for Form1, named Form1.en. resx
When you need to add a new control, you need to switch to the default language.
6. If you have other languages to set, repeat steps 4th and 5th.
7. write code (if you need multi-language support for message boxes, use form as the message box. It also supports multiple languages .)
Meteorology Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using System. Threading;
Using System. Globalization;
Namespace GlobalResource
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void button#click (object sender, EventArgs e)
{
Msg msg = new Msg ();
Msg. ShowDialog ();
}
Private void exit ToolStripMenuItem_Click (object sender, EventArgs e)
{
Application. Exit ();
}
Private void Chinese ToolStripMenuItem_Click (object sender, EventArgs e)
{
// Change the current thread's CultureInfo
// Zh-CN is a Chinese character. For more information about the Culture string, see MSDN.
Thread. CurrentThread. CurrentUICulture = CultureInfo. GetCultureInfo ("zh-CN ");
// Apply the changed resource to the current form
ApplyResource ();
}
Private void ToolStripMenuItem_Click (object sender, EventArgs e)
{
// Change the current thread's CultureInfo
// The en is in English. For more information about the Culture string, see MSDN.
Thread. CurrentThread. CurrentUICulture = CultureInfo. GetCultureInfo ("en"