Best way to make website for multiple languages(制作多语言网站的最佳方式)
问题描述
我使用(Asp.net, c#) 制作了一个网站,其内容为English.现在我需要以支持多种语言的方式制作这个网站,即(德语,法语).Lable/Textbox/string 所有值将显示各自选择的语言在搜索时我开始知道有一些方法像
I have made a website using(Asp.net, c#) and its content in English. Now i have a requirement to make this website in such a way that is support multiple languages ie (German,French). Lable/Textbox/ string all values will display respective selected languages While searching i came to know there are some ways like
- 使用本地化
- 使用资源文件.
- 数据库(每样东西都保存在不同语言的数据库中).
坦率地说,我不同意第三种选择.
frankly speaking I am not agree with 3rd option.
我想知道哪种方式最好还是有其他更好的方式?
I want to know which is the best way to go or is there any other better way?
注意:当前网站是使用 .NET framework 4.0/vs 2010 构建的.
Note:Current Website was built using .NET framework 4.0/ vs 2010.
谢谢
推荐答案
我使用资源文件添加 global.asax 完成的示例代码
Sample code i have done using resource file add global.asax
void Application_BeginRequest(Object sender, EventArgs e)
{
// Code that runs on application startup
HttpCookie cookie = HttpContext.Current.Request.Cookies["CultureInfo"];
if (cookie != null && cookie.Value != null)
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookie.Value);
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookie.Value);
}
else
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
}
}
这篇关于制作多语言网站的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:制作多语言网站的最佳方式
基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
