国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

WEB頁面多語言支持解決方案

2024-07-21 02:25:17
字體:
來源:轉載
供稿:網友

首先建立語言檔,在項目中加入.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
end sub 'application_beginrequest

在web.config中加入如下代碼,用于設定編碼和默認語種,在global.asax中有調用:

======================================================================
<globalization requestencoding="utf-8" responseencoding="utf-8" />
<appsettings>
<add key="defaultculture" value="zh-cn" />
<!-- zh-cn:簡體中文 zh-tw:繁體中文 en:英文 -->
</appsettings>



======================================================================
頁面代碼中使用多語言支持:

imports system.resources

public class 類名
inherits system.web.ui.page
protected locrm as resourcemanager = new resourcemanager("項目文件名.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


======================================================================

到這里多語言支持的工作就作完了,接下來自己去慢慢key
message.zh-cn.resx '簡體中文
message.zh-tw.resx '繁體中文
message.en '英文

這幾個語言檔吧

注冊會員,創建你的web開發資料庫,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桃江县| 五台县| 铅山县| 襄樊市| 雷州市| 遵义市| 根河市| 德惠市| 陆河县| 高阳县| 浦县| 沙河市| 灵武市| 白水县| 虎林市| 根河市| 丹寨县| 揭西县| 田东县| 巴林右旗| 新绛县| 西昌市| 额尔古纳市| 禄丰县| 新乡县| 佛教| 鄱阳县| 高淳县| 龙岩市| 东阳市| 长春市| 山西省| 天峨县| 桦南县| 梅河口市| 乌审旗| 合肥市| 涞水县| 扬州市| 扬州市| 晋中市|