Presentation is loading. Please wait.

Presentation is loading. Please wait.

Global web applications1 Adapting ASP.NET web applications to work in different cultures.

Similar presentations


Presentation on theme: "Global web applications1 Adapting ASP.NET web applications to work in different cultures."— Presentation transcript:

1 Global web applications1 Adapting ASP.NET web applications to work in different cultures

2 Global web applications2 Internationalization, Localization, and Globalization It’s all about adapting software to different cultures –Languages, dates, etc. Internationalization –Designing (or refactoring) software to be adapted to various cultures without changes Localization –Adapting internationalized software to specific cultures Globalization = Internationalization + Localization References –http://en.wikipedia.org/wiki/Internationalization_and_localizationhttp://en.wikipedia.org/wiki/Internationalization_and_localization –http://wiki.asp.net/page.aspx/55/internationalization/http://wiki.asp.net/page.aspx/55/internationalization/

3 Global web applications3 HTTP support for languages HTTP supports user requested languages –HTTP header Content-Language (optional) –RFC 1945: Hypertext Transfer Protocol HTTP/1.0, section “D.2.5 Content-Language” –ASP.NET syntax Request.Headers.Get("Accept-Language") –Syntax: language_COUNTRY en_US –English in USA en_CA –English in Canada fr_CA –French in Canada da_DK –Danish in Denmark

4 Global web applications4 Browser support Browsers can be configured to send specific Content- Language request headers –A prioritized list of … Internet Explorer –Functions → Internet options → General → Languages –You the choose and rank your preferred languages See screen shot Mozilla Firefox –Functions → Options … → Content → Language

5 Global web applications5 Culture aware controls Some ASP.NET controls are culture and language aware –Calendar Page must be –

6 Translating values Global web applications6 Now 10/4/2010 8:40:33 AM Favorite number 145,933,345.00 Price $145.23 protected void Page_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; Response.Write("Now " + now.ToString()); Response.Write(" "); int favoriteNumber = 145933345; Response.Write("Favorite number " + favoriteNumber.ToString("n")); Response.Write(" "); double price = 145.23; Response.Write("Price " + price.ToString("c")); } Now 04-10-2010 08:42:46 Favorite number 145.933.345,00 Price kr. 145,23

7 Global web applications7 How to internationalize texts 1.Make a working web site in some language 2.Make sure all texts, etc. are in 3.Make sure all elements have good ID’s –ID’s will be used as the key in the localization database 4.If you have texts set in C# (error messages for example) –Temporarily copy the texts to the.aspx file 5.Internationalize + Generate the default locale –Visual Studio: Design mode: Tools -> Generate Local Resource Editor must be in “Design Mode” –No such help in Visual Web Developer  6.Try the web site 7.Delete the temporary texts from the.aspx file

8 How to localize texts 1.Copy the file default.aspx.resx to localize another culture, like default.aspx.da.resx –Danish language + culture: da 2.Rewrite all the texts in the copy 3.Try the web site with a browser configured to request the Danish language version 4.Texts set in code-behind (C#) –LabelDuplicateMessage.Text = GetLocalResourceObject( "LabelDuplicateMessageResource1.Text "). ToString() Global web applications8

9 References Bill Evjen Professional ASP.NET 4 in C# and VB, Wrox 2010 –Chapter 32: Building Global Applications, page 1217- 1238 ASP.NET Globalization and Localization –http://msdn.microsoft.com/en- us/library/c6zyy3s9.aspxhttp://msdn.microsoft.com/en- us/library/c6zyy3s9.aspx Microsoft.NET – Internationalization –http://msdn.microsoft.com/en- us/goglobal/bb688096.aspxhttp://msdn.microsoft.com/en- us/goglobal/bb688096.aspx Global web applications9


Download ppt "Global web applications1 Adapting ASP.NET web applications to work in different cultures."

Similar presentations


Ads by Google