Web page multilingual support solution

xiaoxiao2021-03-06  19

First establish a language file, join .e.resx file, for example: message.zh-cn.resx 'simplified Chinese message.zh-tw.resx' 体 ​​中文 Message.en 'English ......... ... =============================================== ======================= Then use the Name -Value key value to fill in the language displayed on the page such as: name value message.zh- CN.RESX: RES_LOGINBNAME Land Name: Message.zh-Tw.resx: RES_LOGINBNAME Land Name: rssage.zh-cn.resx: Res_loginbname login name: =============== ============================================================================================================================================================================================================= ===== Then add multilingual setting support code in Golbal.asax (the browser needs to support cookie) '======================== ============================================================================================================================================================================================================= =================1 ''

The Thread Culture Is Set for Each Request Using the Language 'Settings'' =================================== ============================================================================================================================================================================================================= ======== Sub Application_BeginRequest (ByVal sender As Object, ByVal e As EventArgs) TryIf Not Request.Cookies ( "resource") Is Nothing Or Request.Cookies ( "resource"). Value = "" ThenThread.CurrentThread .CurrentCulture = CultureInfo.CreateSpecificCulture (Request.Cookies ( "resource"). Value) ElseThread.CurrentThread.CurrentCulture = New CultureInfo (ConfigurationSettings.AppSettings ( "DefaultCulture")) End IfThread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCultureCatch ex As ExceptionThread.CurrentThread.CurrentCulture = New CultureInfo (ConfigurationSettings.AppSettings ( "DefaultCulture")) End TryEnd Sub 'Application_BeginRequest in Web.Config added the following code, and coding for setting default language, there are calls in the Global.asax: = ============================================================================================================================================================================================================= ===================

ResponseEncoding = "UTF-8" /> =============================================== ======================== In the page code, use multilingual support: imports system.resourcespublic class name inherits system.web.ui.pageprotace 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.LoadlblLogin.Text = LocRM.GetString ( " Res_login ") End subs class ============================================ ========================== From the work of multi-language support, let go of itself to slowly KeyMessage.zh-cn.resx 'Simplified Chinese Message.zh-Tw.resx' Traditional Chinese Message.en 'English these language files

转载请注明原文地址:https://www.9cbs.com/read-40436.html

New Post(0)