Globalization support in ASP.NET

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
Unit 5: Building Presentation Layer Applications with ASP.NET 2.0.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Sophia Antipolis, September 2006 Multilinguality, localization and internationalization Miruna Bădescu Finsiel Romania.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.

Dr. Azeddine Chikh IS444: Modern tools for applications development.
WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.
The Company….  The Market Leader in Globalization Technology –Pioneers in visual translation environments –Solutions for major platforms & programming.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Lecture Set 1 Part C: Understanding Visual Studio and.NET – Applications, Solutions, Projects (no longer used – embedded in Lecture Set 2A)
Globalization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle western languages and Arabic with a single code base.
DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
CIS 375—Web App Dev II ASP.NET 8 More Binding. 2 The Repeater ControlThe Repeater Control 1 The Repeater control is used to display a repeated list of.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
Localization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
Internationalization in ASP.NET 2.0. SQL Server 2005 – Data Columns Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations Use Unicode.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
CSE 409 – Advanced Internet Technology Today you will learn  Styles  Themes  Master Pages Themes and Master Pages.
DEV392.NET Framework: Building Applications With Globalization In Mind Michele Leroux Bustamante Principal Software Architect IDesign Inc.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Configuring and Deploying Web Applications Lesson 7.
Internationalization Andres Käver, IT Kolledž 2015.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Can I have separate Store of My website for Different set of Users.
7/23/2016 CSC 325 Advanced Programming Techniques Localization Slide #1 1 Localization Mikhail Brikman.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 6: The User Interface (UI) Dave.
Random Logic l Forum.NET l Localization & Globalization Forum.NET ● May 29, 2006.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Implementing Subprograms
Architecture Review 10/11/2004
4.01 How Web Pages Work.
Java FX: Scene Builder.
Computing with C# and the .NET Framework
ASP.NET Forms.
Unit 7 Learning Objectives
In this session, you will learn to:
Creating Oracle Business Intelligence Interactive Dashboards
Metropolia 2013 C# programming and .NET framework
Displaying XML Data with XSLT
Session Variables and Post Back
About SharePoint Server 2007 My Sites
Learning the Basics – Lesson 1
Activities and Intents
Building Web Applications with Microsoft ASP
Unit 27 - Web Server Scripting
Implementing Subprograms
Application Infrastructure
Anatomy of an ASP.NET Page
Developing International Applications with Visual Studio 2005
PHP.
Tonga Institute of Higher Education
ASP.NET.
Web Development Using ASP .NET
Guidelines for Microsoft® Office 2013
Implementing Subprograms
Security - Forms Authentication
Presentation transcript:

Globalization support in ASP.NET

Globalization Globalization is the process of creating an application that meets the needs of users from multiple cultures. This process involves more than just translating the user interface elements of an application into multiple languages—it also includes using the correct currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.

Localization Localization – providing content in a region specific culture and language. Culture determines date display settings, e.g.: mm-dd-yyyy or dd/mm/yyyy, currency display formats etc.

Ways to Globalize Web Applications There are several different approaches to creating Web applications that support multiple cultures: Detect and redirect Run-time adjustment Satellite assemblies (using Resource Files) – preferred method

Detect and Redirect Create a separate Web application for each supported culture, and then detect the user’s culture and redirect the request to the appropriate application.

Run-time adjustment Create a single Web application that detects the user’s culture and adjusts output at run time using format specifiers and other tools.

Satellite assemblies Create a single Web application that stores culture-dependent strings in resource files that are compiled into satellite assemblies. At run time, detect the user’s culture and load strings from the appropriate assembly.

Detecting the User’s Culture Microsoft ASP.NET uses the Request object’s UserLanguages property to return a list of the user’s language preferences. The first element of the array returned by UserLanguages is the user’s current language. Use that value to create an instance of the CultureInfo class representing the user’s current culture. To get the user’s culture at run time, follow these steps: Get the Request object’s UserLanguages property. Use the returned value with the CultureInfo class to create an object representing the user’s current culture.

Detecting the User’s Culture Dim sLang As String ' Get the user's preferred language. sLang = Request.UserLanguages(0) ' Create a CultureInfo object from it. Dim CurrentCulture As New CultureInfo(sLang) lblCulture.Text = CurrentCulture.EnglishName  & ": & _ CurrentCulture.Name

sLang = sLang.Substring(0, 2) If sLang = "en“ Then ' Use US site. Response.Redirect("http://www.blah.com/usa") ElseIf sLang = "es“ ' Use Spanish site. Response.Redirect("http://www.blah.com/es") ElseIf sLang = "de“ ' Use German site.              Response.Redirect("http://www.blah.com/de") End If

Setting Culture in Web.config Use the Web.config file’s globalization element to create a culture-specific Web application. The culture attribute of the globalization element specifies how the Web application deals with various culture-dependent issues, such as dates, currency, and number formatting. <globalization requestEncoding="utf-8" responseEncoding="utf-8"    culture=“en-US“ uiCulture=“en-US" />

Setting culture for Web page Auto detection of culture (default): <%@ Page culture="auto" uiculture="auto" %> Explicitly setting culture: <%@ Page culture=“ru-RU“ uiculture=“ru-RU" %>

Adjusting to Current Culture at Run Time When you set the culture attribute for a Web application in Web.config, ASP.NET assigns that culture to all the threads running for that Web application. Threads are the basic unit to which the server allocates processor time—ASP.NET maintains multiple threads for a Web application within the aspnet_wp.exe worker process. Using Web.config to set the culture creates a static association between the application and a specific culture. Alternatively, you can set the culture dynamically at run time using the Thread class’s CurrentCulture property

Setting Culture at Run Time Dim sLang As String      ' Get the user's preferred language. sLang = Request.UserLanguages(0) ' Set the thread's culture to match the user culture.       Thread.CurrentThread.CurrentCulture = New CultureInfo(sLang) The preceding code detects the user’s culture and then sets the culture of the current thread to match. ASP.NET will then format date, currency, and numeric strings using the user’s culture

Setting Culture at Run Time Using Page properties Culture and UICulture to set culture: Culture– determines results of culture dependent functions, accepts cultures that define both language and country(region), e.g. en-US, fr-FR but not just: en, fr UICulture – determines which resources are loaded for the page, accepts both neutral and specific cultures e.g.: en, en-US

Setting Culture at Run Time To draw form components with new culture set, Culture setting should be done in InitializeCulture() not in Page_Load() Protected Overrides Sub InitializeCulture() If Not (Request.Form(“ddC") Is Nothing) Then Culture = Request.Form("ddC") UICulture = Request.Form("ddC") MyBase.InitializeCulture() End If End Sub

Globalization using Resource Files Local resources - Implicit localization Uses page specific resource files, stored in App_LocalResources folder Global resources - Explicit localization Uses single resource file, should be used when it is required to access a single resource from multiple pages, stored in App_GlobalResources folder

Local resources (Implicit localization) Should be stored in subfolder App_LocalResources of the folder containing web pages. Resource file should be named using format: PageName<.culture>.resx e.g.: Default.resx Default.en-US.resx Default.ru.resx

Creating local resource files Could be created: Manually Generate using VS.NET tool (preferred method) Create resource files when you complete creation of your page and you will have all components you need on the page

Creating local resource files manually Create App_LocalResources sub folder in the same folder where you have you web page In App_LocalResources create resource files with names matching pattern: PageName<.culture>.resx For every text entry that needs to be translated create a Name/Value in resource file, e.g.: Label1Resource1.Text - Username

Creating local resource files manually In web page add meta:resourcekey attributes to all components that need to be translated <asp:Label ID="Label1" runat="server" meta:resourcekey="Label1Resource1" Text=“Username"></asp:Label>

Creating local resource files automatically All these steps described above could be done by VS.NET automatically: Open web page in design view Go to top menu: Tools -> Generate Local Resources

Creating global resources (explicit localization) Create App_GlobalResources in the root folder of the web site In App_GlobalResources create resource file with any name. For every text entry that needs to be translated create a Name/Value in resource file, e.g.: global.AppTitle – My Web App For every culture you want to support create a resource file with corresponding translations and add culture identifier immediately before the .resx extention, e.g.: myGlobal.ru.resx

Associating controls with global resources – step 1

Associating controls with global resources – step 2

Associating controls with global resources – results <asp:Label ID="Label5" runat="server" Text="<%$ Resources:translations, title %>"> </asp:Label>

Access resource values programmatically After saving resource file VS.NET creates strongly typed members for every global resource value, e.g.: Label5.Text = Resources.Translations.title

References http://msdn.microsoft.com/en- us/library/c6zyy3s9%28v=VS.90%29.aspx http://www.codeproject.com/Kb/aspnet/localiz ationByVivekTakur.aspx