Visual Studio provides a complete solution for. NET Program localization. In order to enable Software Internationalization and localization, this article provides a simple description and tips.
I. Internationalization solution of forms
After creating a new WinForm solution, select the main form, right-click to view the properties, find the Localizable attribute, set it to True, find the Language attribute, and select the Language to switch, for example, English (U.S.), Chinese (simplified, Chinese), etc. In this case, the style and Language of the form in the Language are designed according to the actual situation.
Figure 1 Form attribute settings
Figure 2 resource files automatically generated based on the selected language
Ii. Use the CultureInfo class to implement international solutions
The CultureInfo class contains regional-specific information, such as languages, countries, calendars, and regional conventions.
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Windows. Forms;
Namespace LocationForm
{
Static class Program
{
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[STAThread]
Static void Main ()
{
Application. EnableVisualStyles ();
Application. SetCompatibleTextRenderingDefault (false );
// System. Threading. Thread. CurrentThread. CurrentUICulture = new System. Globalization. CultureInfo ("en-US ");
System. Threading. Thread. CurrentThread. CurrentUICulture = new System. Globalization. CultureInfo ("zh-CN ");
Application. Run (new Form1 ());
}
}
}
Iii. Effects
Iv. References
Coding and localization http://msdn.microsoft.com/zh-cn/library/h6270d0z.aspx
From Xue jingming's column