First create 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
message.zh-cn.resx:
res_loginbname login name:
message.zh-tw.resx:
res_loginbname login name:
message.zh-cn.resx:
res_loginbname Login Name :
=========================================
Then add multi-language setting support code in Golbal.asax (the browser needs to support Cookie)
'============================== ============
'Application_BeginRequest Event
'
' The Application_BeginRequest method is an ASP.NET event that executes
' on each web request into the portal application.
'
' The thread culture is set for each request using the language
' settings
'
'==========================================
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Try
If Not Request.Cookies("resource") Is 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 to Web.Config to set the encoding and default language. It 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:Traditional Chinese en:English-->
</appSettings>
=========================================
Multi-language support is used in the 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
=========================================
The multi-language support work is done here. It’s done, then go and Key it yourself slowly
message.zh-cn.resx 'Simplified Chinese
message.zh-tw.resx 'Traditional Chinese
message.en 'English
language files?