Globalization and Localization in asp.net

ε祈祈猫儿з 提交于 2019-12-13 20:19:19

问题


We need to develop an ASP.NET 3.5 Web application, which should support Japanese and English languages. If the user is accessing from Japan, then our application should open in Japanese; otherwise, our application should open in English. How can we achieve this requirement? Sample code is very welcome.

Thanks.


回答1:


Your question is too broad and yet you expect a code sample. This is an architectural decision, first familiarize yourself with the ASP.NET Globalization mechanisms and then ask more specific questions.

Here are some related posts you will find useful:

  • What do I need to know to globalize an asp.net application?
  • How to acheive multilingaul support in ASP.NET



回答2:


Simply make a basepage class that will inherited from Page class, put this method in basepage class and inherit basepage class in your every aspx.cs page to acheive globalization.

protected override void InitializeCulture() 
{ 
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); 
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
base.InitializeCulture(); 
}

set culture in this method whatever you want, you can put culture in session variable and whenever user switch language simply change session ..

in your case session value could be en-US,ja



来源:https://stackoverflow.com/questions/1818631/globalization-and-localization-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!