Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

WEB页面多语言支持解决方案

来源:中文源码网    浏览:340 次    日期:2024-05-13 03:17:02
【下载文档:  WEB页面多语言支持解决方案.txt 】


WEB页面多语言支持解决方案
首先建立语言档,在项目中加入.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)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在Web.Config中加入如下代码,用于设定编码和默认语种,在Global.asax中有调用:========================================= =========================================页面代码中使用多语言支持:Imports System.ResourcesPublic Class 类名Inherits System.Web.UI.PageProtected LocRM As ResourceManager = New ResourceManager("项目文件名.message", GetType(类名).Assembly)Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadlblLogin.Text = LocRM.GetString("res_login")End SubEnd Class=========================================到这里多语言支持的工作就作完了,接下来自己去慢慢Keymessage.zh-cn.resx '简体中文message.zh-tw.resx '繁体中文message.en '英文这几个语言档吧

相关内容