Title: .NET Framework multi-language support implementation Keywords: .NET multilingual Author: dREAMtHEATER Difficulty: Normal [x] Medium [] High [] http: //dREAMtHEATER.yeah.netE-Mail: NoteXPad@163.com Date: August 02, 2004, Foreword once remembered the era of win32's native code programming. In order to achieve a multilingual interface, the brain juice, so a lot of tutorials teach you how to make the program to implement multi-language support, these The technical level of implementation methods is uneven, it is difficult to find a good framework to achieve in business programs. The arrival of the .NET era, we suddenly found that all this is so simple, you can make your program perfect multi-language support. I don't want to explain the concepts of excessive explanation here because MSDN has provided us with a fully localized technical documentation. Text I use Visual C # .NET in Visual Studio 2003, this Demo I design can automatically realize the localization of current zone settings, but also manually change the interface language and realize local local locations. . Demo Source Code Download here. Please follow my steps:
Create a new Windows application called "Multilanguage". In the Properties window, set the localizable property of the form to True. The Language property is set to (default). Drake MainMenu, PictureBox, dragged from the "Windows Form" tab of "Toolbox" to the form, then set up the layout, design of these controls in the DEMO form. Set the list of the list to "Chinese (People's Republic of China)." Re-press the layout and design of the Chinese interface of these controls in the DEMO form. Click the "Show All File" buttons in the Solution Explorer. The resource file appears below Form1.cs. Form1.resx is a backup regional resource file that will be generated to the main assembly. Form1.en-cn.resx is a resource document of Simplified Chinese in China. Generate the Click event of the menu item separately, follow the implementation code I am in Demo to the event processing section. Everyone is primarily learning how I dynamically modify all the language-related elements on the interface, including strings, objects (such as PictureBox.image). Click Add New Item on the Project menu. Select the "Spring Resource File" template in the Template box. Type "Winformstrings.resx" in the Name box. The winformstrings.resx file will contain English backup resources. These resources will be accessed whenever the application is not more suitable for the UI regional resource. This file is added to the project in the Solution Explorer and is automatically opened in the XML designer. Select "DATA" in the Dataset pane. In the "Data" pane, click Block and Enter "StrMessage" in the "Name" column, enter "Hello World" in the Value column. On the File menu, click Save WinFormStrings.resx. Perform two steps 8-12 to create a resource file called "winformstrings.en-cn.resx", and this file has the string resources specified in the table below. The winformstrings.zh-cn.resx file will contain resources specific to China's English-speaking.
Resource file name namevaluewinformstrings.zh-cn.resxStrMessage Hello! world
Generate the Click event of Button1, and add it to the event processing section according to the implementation code I am in DEMO. Some of this part mainly learns how to access manual additive resources, and its purpose is to generate a localized string that appears in dialogs and error messages when you program. Add the code for the constructor FORM1 (), follow the code I am in Demo. Save and generate solutions. Compiled and tried to run. I am compiled with the Release mode. In the project directory Multilanguage / Bin / release, two subdirectories "zh-chs", "zh-cn" are generated, and there is a file called "multilaage.resources.dll". The resource files corresponding to the backup area you designed in the form. Please publish along with the last compiler, do not change any directory settings in the bin directory,. Net Framework will be implemented in accordance with certain laws, please refer to the corresponding chapter of the MSDN. reference
MSDN Feb 2003 Simplified Chinese version. See MS-Help: //ms.msdnqtr.2003feb.2052/vbcon/html/vbwlkwalkthroughlocalizingWindowsForms.htm