ASP.NET中如何实现多语言???

hongsushou 2005-01-04 11:38:12
我在网上找过例子,但是不是很好,具体怎么实现啊?

还有我下了那个ASP.NET论坛的源码,里面有多语言的解决方法,可是我看不懂啊?谁能给讲讲!
...全文
174 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
SnApnet 2005-01-04
  • 打赏
  • 举报
回复
楼上几位都说了,没别的办法了。
goody9807 2005-01-04
  • 打赏
  • 举报
回复
建立语言档
jiezhi 2005-01-04
  • 打赏
  • 举报
回复
http://www.cnblogs.com/hotsoho.net/archive/2005/01/03/85978.html
ceocio 2005-01-04
  • 打赏
  • 举报
回复
转:

首先建立语言档,在项目中加入.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 '英文
xiaodao2008 2005-01-04
  • 打赏
  • 举报
回复
一种语言能解决不就行了吗?搞那么多干嘛呢!
在ASP.NET中只要不在同一个Web窗体内使用多种语言就行了,可以使用其它语言开发的控件,使用其它语言开发的页面
sean168 2005-01-04
  • 打赏
  • 举报
回复
同意 ceocio(MS .Net / IIS MVP)(SWJTU) ( )
我们的系统就是这样实现的

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧