Based on ASP.NET to achieve globalization due to project relationships, these two days have been studying the globalization of ASP.NET. I know that there is a special I18N processing scheme in the Java system, and there is no possibility in .NET. Therefore, check the information on the Internet, after some "bitter", slightly smaller. I don't have a very complete solution online (may I have not found), I spent some lessons, I hope to share with you. If you have any deficiencies, please advise. In this article, the basic steps to implement globalization in ASP.NET will be described in the way in VS.NET2002, and where they need to pay attention will be described. The first step, we created a Web Application called TestRM. This project will be default - AssemblyInfo.cs - Testrm.csproj - Testrm.csproj.Webinfo - Testrm.SLN - Testrm.suo - Testrm.Vsdisco - Webform1.aspx (including AspX.cs and Asp cpx.resx) - Global.asax (Including asax.cs and asax.resx) - Web.config Step 2, you need to create a number of different language resource files for the project. In .NET, the extension of the resource file is .resx, this file is basically XML, VS.NET provides a very convenient resource file editing tool (personal feeling very like Xmlspy), there is not much to say. Here, as an example of Simplified Chinese (EN-CN) and US English (EN-US). Adding a resource file named string.en-usx and string.zh-cn.resx, adding a String.en-US.resx, adding a String.en-US.resx, adding a String.en-US.RESX to the project. A record, content is name: string001; value: Welcome, add a record in String.en-cn.resx Name: string001; Value: Welcome. The structure of the XML file is as follows: XML Version = "1.0" encoding = "UTF-8"?>
First, we need to add the event in Global.asax Application_BeginRequest following code: protected void Application_BeginRequest (Object sender, EventArgs e) {Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture (ConfigurationSettings.AppSettings [ "DefaultCulture"]);} This is the The simplest application, of course, you can store some configuration items into cookies. Then, add the following code in Web.config: