国产探花免费观看_亚洲丰满少妇自慰呻吟_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開發資料庫,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉木萨尔县| 夹江县| 额敏县| 开江县| 赤城县| 罗甸县| 清远市| 宁武县| 三亚市| 蒲城县| 敖汉旗| 荆州市| 大余县| 齐河县| 松阳县| 北宁市| 新昌县| 南陵县| 苗栗县| 白玉县| 竹山县| 竹北市| 东方市| 南汇区| 错那县| 新沂市| 密山市| 札达县| 锡林郭勒盟| 德惠市| 教育| 衡阳市| 临夏市| 东乡| 贺州市| 廉江市| 和龙市| 疏附县| 桂东县| 陆川县| 武山县|