日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

WEB页面多语言支持解决方案(转自CSDN)

發(fā)布時(shí)間:2025/3/13 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WEB页面多语言支持解决方案(转自CSDN) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
首先建立語(yǔ)言檔,在項(xiàng)目中加入.resx文件 ?
例如: ?
message.zh-cn.resx ?'簡(jiǎn)體中文 ?
message.zh-tw.resx ?'繁體中文 ?
message.en ? ? ? ? ? ? ? ? ?'英文 ?
.............. ?
?
====================================================================== ?
然后利用Name ?--Value ?鍵值對(duì) ?填入你要在頁(yè)面上顯示的語(yǔ)言 ?
如: ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?name ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?value ? ?
message.zh-cn.resx中: ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?res_loginbname ? ? ? ? ? ? ? ? ? ? ? ?登陸名 ?: ?
message.zh-tw.resx中: ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?res_loginbname ? ? ? ? ? ? ? ? ? ? ? ?登陸名 ?: ?
message.zh-cn.resx中: ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?res_loginbname ? ? ? ? ? ? ? ? ? ? ? ?Login ?Name ?: ?
?
?
?
====================================================================== ?
然后在Golbal.asax中加入多語(yǔ)言設(shè)定支持代碼(瀏覽器需要支持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 ?
?
在Web.Config中加入如下代碼,用于設(shè)定編碼和默認(rèn)語(yǔ)種,在Global.asax中有調(diào)用: ?
?
====================================================================== ?
? ? ? ?<globalization ?requestEncoding="utf-8" ?responseEncoding="utf-8" ?/> ?
? ? ? ? ? ? ? ?<appSettings> ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<add ?key="DefaultCulture" ?value="zh-cn" ?/> ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<!-- ? ? ?zh-cn:簡(jiǎn)體中文 ?zh-tw:繁體中文 ?en:英文 ? ? ? ?--> ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ?</appSettings> ?
?
?
?
====================================================================== ?
頁(yè)面代碼中使用多語(yǔ)言支持: ?
?
Imports ?System.Resources ?
?
Public ?Class ?類名 ?
? ? ? ?Inherits ?System.Web.UI.Page ?
? ? ? ?Protected ?LocRM ?As ?ResourceManager ?= ?New ?ResourceManager("項(xiàng)目文件名.message", ?GetType(類名).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 ?
?
?
====================================================================== ?
?
到這里多語(yǔ)言支持的工作就作完了,接下來(lái)自己去慢慢Key ?
message.zh-cn.resx ?'簡(jiǎn)體中文 ?
message.zh-tw.resx ?'繁體中文 ?
message.en ? ? ? ? ? ? ? ? ?'英文 ?
?
這幾個(gè)語(yǔ)言檔吧,這是一個(gè)痛苦的回憶!??

轉(zhuǎn)載于:https://www.cnblogs.com/acelove/archive/2005/01/27/98191.html

與50位技術(shù)專家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的WEB页面多语言支持解决方案(转自CSDN)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。