VB 源码VC 源码ASP源码JSP源码PHP源码CGI源码FLASH源码素材模板C 源程序常用软件文档中心其他程序

.NET技术

编程开发
PHP技术
JSP技术
ASP技术
.NET技术
数据库

本类阅读TOP10

·ASP.NET提供文件下载函数
·ASP.NET中使用数据处理插入数据注意的问题
·带你走进ASP.NET(4)
·如何让你的服务器支持asp.net
·ASP.net生成文字图片
·从ASP过渡到ASP.net遗留的二十大积习
·带你走进ASP.NET(3)
·带你走进ASP.NET(1)
·ASP.NET可交互式位图窗体设计(9)
·ASP.NET可交互式位图窗体设计(1)

精品推荐
ASP.NET WEB页面多语言支持解决方案

作者:佚名 来源:月光软件站 加入时间:2005-3-1 月光软件站

首先建立语言档,在项目中加入.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中有调用:

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




=================================================
页面代码中使用多语言支持:

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         '英文

这几个语言档吧,这是一个痛苦的回忆!


语言的后缀 如:
zh-cn'简体中文
zh-tw'繁体中文
en   '英文

可以参考 IE选项---网际网络设定--〉一般选项卡语言--〉新增里边的内容




相关文章
  • IIS的安全问题与解决方案
  • 基于NT(2000)建立安全WEB站点的解决方案
  • 10元打造三机互联方案
  • IE浏览器又发现致命漏洞 目前尚无解决方案
  • 相关软件




    月光软件程序下载编程文档电脑教程网站设计网址导航网络文学游戏天地幽默笑话生活休闲写作范文安妮宝贝
    电脑技术编程开发网络专区谈天说地情感世界游戏元素分类游戏热门游戏体育运动手机专区业余爱好影视沙龙
    音乐天地数码广场教育园地科学大观古今纵横谈股论金人文艺术医学保健动漫图酷二手专区地方风情各行各业

    月光软件站·版权所有