First set up the language file and add the. resx file to the project
For example:
Message.zh-cn.resx ' Simplified Chinese
Message.zh-tw.resx ' Traditional Chinese
Message.en ' English
..............
=========================================
Then use the name--value key value pair to fill in the language you want to display on the page
Such as:
Name value
In Message.zh-cn.resx:
Res_loginbname Login Name:
In Message.zh-tw.resx:
Res_loginbname Name:
In Message.zh-cn.resx:
Res_loginbname Login Name:
=========================================
Then, add the multi-language setting support code in the Golbal.asax (the browser needs to support cookies)
'=========================================
' Application_BeginRequest Event
'
' The Application_BeginRequest method is a ASP.net event that executes
' On a Web request into the portal application.
'
' The thread culture is set to each request using the language
' Settings
'
'=========================================
Sub Application_BeginRequest (ByVal sender as Object, ByVal e as EventArgs)
Try
If not Request.Cookies ("resource") are nothing Or request.cookies ("resource"). Value = "" Then
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture (Request.Cookies ("resource"). Value)
Else
Thread.CurrentThread.CurrentCulture = New CultureInfo (configurationsettings.appsettings ("Defaultculture"))
End If
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture
Catch ex as Exception
Thread.CurrentThread.CurrentCulture = New CultureInfo (configurationsettings.appsettings ("Defaultculture"))
End Try
End Sub ' Application_BeginRequest
Add the following code in Web.config to set the encoding and default language, which is called in Global.asax:
=========================================
<globalization requestencoding= "Utf-8" responseencoding= "Utf-8"/>
<appSettings>
<add key= "Defaultculture" value= "ZH-CN"/>
<!--ZH-CN: Simplified Chinese zh-tw: Chinese en: English-->
</appSettings>
=========================================
Multi-language support in page code:
Imports System.Resources
public class class name
Inherits System.Web.UI.Page
Protected Locrm as ResourceManager = New ResourceManager ("project file name. Message", GetType (class name). Assembly)
Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
Lbllogin.text = locrm.getstring ("Res_login")
End Sub
End Class
=========================================
To the multilingual support of the work done, then go to slowly key
Message.zh-cn.resx ' Simplified Chinese
Message.zh-tw.resx ' Traditional Chinese
Message.en ' English
These are some language files.