App_GlobalResources in ASP. NET 2.0 can be used to solve localization problems, and the program will automatically determine the localized interface based on the browser's language preferences.
First create a new RESX resource file in App_GlobalResources. Such as:
Items in the ResX in different languages should have the same name:
Chinese resource Item
English resource items
When you're done, you can use these name values.
<asp:literal id= "Literal1" runat= "Server" text= "<%$ resources:lang,userinfo%>"/>
Or
<%=Resources.lang.userinfo%>
Now you can change your browser's language preferences to see the results.
The next question is how to change the language item by the way the program itself.
1. You can add <globalization culture= "en-us" uiculture= "en-us"/> to the Web. config to change the language items that the program uses by default.
2. You can add the following code to the global application
void Application_BeginRequest (Object sender, EventArgs e) { Try { if (request.cookies["lang"]! = NULL) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture ( request.cookies["Lang"]. Value.tostring ()); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo (request.cookies[" Lang "]. Value.tostring ()); } } catch (Exception) &NBSP;&NBsp; {} }
Can be set to change the value of the cookie to achieve the purpose of instant switching language, easy to implement the program's multi-language.
can also use other tags to achieve the purpose of switching languages, first write down to first
. NET Multi-lingual support solutions (RPM)