ASP.NET Web Page Multilingual Support Solutions
Choose from Johnlen's BLOG keyword ASP.NET Web page multilingual support solution to build a language file first, join .Resx file, for example: message.zh-cn.resx '简体 中文 Message.zh-tw.resx' Traditional Chinese Message.en 'English ............
============================================================================================================================================================================================================= ==================== Then use the name -value key value to fill in the language you want to display on the page such as: name value message.zh-cn.resx Medium: RES_LOGINBNAME Land Name: Message.zh-Tw.RESX: RES_LOGINBNAME Land Name: Message.zh-cn.resx: Res_loginbname Login Name:
============================================================================================================================================================================================================= ==================== Then add multilingual setting support code in Golbal.asax (the browser needs to support cookies)
'==================================================== ==================================================== 'Application_BeginRequest Event' ' 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 E AS Object, BYVAL E AS Eventargs) TRY 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 In Web.Config Add the following code to set the encoding and default language, there is called in global.asax:
============================================================================================================================================================================================================= =====================
============================================================================================================================================================================================================= ==================== Using multilingual support in page code:
Imports system.resources
Public Class Your Class Inherits System.Web.ui.page Protected LoCRM As ResourceManager = New ResourceManager ("Project File Name .Message", gettype (class name) .assembly
Private sub page_load (Byval E AS System.EventArgs) Handles mybase.load lbllogin.text = LoCRM.GETSTRING ("res_login") End Subend class ============== ============================================================================================================================================================================================================= =======
It's finished with the work of multilingual support here, next to yourself KeyMessage.zh-cn.resx 'Simplified Chinese Message.zh-Tw.resx' Traditional Chinese Message.en 'in English
These languages, this is a painful memory!
The suffix of language such as: zh-cn 'simplified Chinese en-TW' Traditional Chinese EN 'English
Can refer to IE Options - Network Settings -> General Tab Language -> Content
Author Blog: http://blog.9cbs.net/johnlen/