开发者

Globalization and Localization in asp.net

开发者 https://www.devze.com 2022-12-13 00:33 出处:网络
We need to develop an ASP.NET 3.5 Web application, which should sup开发者_如何学Goport Japanese and English languages. If the user is accessing from Japan, then our application should open in Japanese

We need to develop an ASP.NET 3.5 Web application, which should sup开发者_如何学Goport 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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消