首先建立語言檔,在項目中加入.resx文件
例如:
message.zh-cn.resx '簡體中文
message.zh-tw.resx '繁體中文
message.en '英文
..............
============================================
然後利用Name --Value 鍵值對 填入你要在頁面上顯示的語言
如:
name value
message.zh-cn.resx中: res_loginbname 登陸名 :
message.zh-tw.resx中: res_loginbname 登陸名 :
message.zh-cn.resx中: res_loginbname Login Name :
=============================================
然後在Golbal.asax中加入多語言設定支持代碼(浏覽器需要支持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