导航:业界 | 认证 | 工具 | 图形 | 技术 | 系统 | 网络 | 办公 | 网页 | 文摘 | 动画
您当前的位置:diva8.com -> I T -> 技术 -> .Net专栏 -> I T内容
栏目导航
· .Net专栏 · Script
· ASP学院 · PHP学院
· Web服务器 · CGI学院
· XML学院 · SQL学院
· JSP学院 · SMS学院
热门I T
· [组图] 音频后期处理Adobe ...
· [组图] Photoshop--照片处理...
· [组图] 廉颇老矣?IE7.0 Bet...
· [图文] DuDu下载加速器推出...
· [组图] 清晰还原!Photoshop...
· [组图] 用photoshop给图片祛...
· [组图] DuDu 下载加速器试用...
· [组图] 新春特别版:PPLIVE...
· [图文] 让查找更方便些 腾讯...
· [组图] 廉颇老矣?IE7.0 Bet...
相关I T
· “IIS配置401错误”...
· 打印问题解决方案集...
· [组图] 非因特网用户Window...
· [图文] 金山毒霸五毒虫病毒...
· 忘记登录密码的解决...
· 内存错误的整体解决...
· QQ被加小尾巴的解决...
· 消费者信息网站解决...
· [组图] Novarg恶性蠕虫病毒...
· [组图] 轻松制作自己的信息...
WEB页面多语言支持解决方案
作者:admin  来源:齐昌网络  发布时间:2005-4-3 15:46:39  发布人:qichang

减小字体 增大字体


首先建立语言档,在项目中加入.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 '英文

这几个语言档吧



[] [返回上一页] [打 印] [收 藏]
∷相关I T评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 在线人数:
diva8.com Copyright © 2001-2006 diva8.com All Rights Reserved .粤ICP备05014750号