求助:

tyhuang 2005-06-13 03:11:31
我现在编好一个中文的asp.net的web程序

请问如何把它改成英文的版本,同时中文的不变

...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qingyun1020 2005-06-13
  • 打赏
  • 举报
回复
还是支持中英各一套。
luckyprg 2005-06-13
  • 打赏
  • 举报
回复
这种可能要像C/S的那种一样,用资源文件来实现吧。
goody9807 2005-06-13
  • 打赏
  • 举报
回复
首先建立语言档,在项目中加入.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 '英文
lemong 2005-06-13
  • 打赏
  • 举报
回复
字符资源挑出来,中英各一套,根据需要显示
xzq686 2005-06-13
  • 打赏
  • 举报
回复
.net可以实现全球化,可以支持中文,英文,文章繁体.的自由转化.你可以参照下面的文章.

.NET 多语言解决方案(demo篇)
http://www.cnblogs.com/hotsoho.net/archive/2005/01/03/85978.aspx
基于ASP.NET实现全球化
http://www.cnblogs.com/tonyjoule/archive/2005/04/20/9504.html
powerllr 2005-06-13
  • 打赏
  • 举报
回复
笨方法
再做一个E文的

62,266

社区成员

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

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

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

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