Internationalization in ASP.NET 2.0. SQL Server 2005 – Data Columns Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations Use Unicode.

Slides:



Advertisements
Similar presentations
Advanced.Net Framework 2.0 David Ringsell MCPD MCSD MCT MCAD.
Advertisements

Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Building International Applications with Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corporation.
Developing Arabic Applications with Visual Studio 2005 Dina Lasheen Program Manager – Developer Division.
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
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.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Basics of ASP.NET. 2 © UW Business School, University of Washington 2004 Outline Installing ASP.NET and Web Matrix Data Types Branching Structure Procedures.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
ASP.NET Programming with C# and SQL Server First Edition
ASP.NET Programming with C# and SQL Server First Edition
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Overview of SQL Server Alka Arora.
Mark Frederiksen ABLE Innovations i18n (Internationalization) in ASP.NET 2.0.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Microsoft Visual Basic 2005: Reloaded Second Edition
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.
Using Visual Basic 6.0 to Create Web-Based Database Applications
The Company….  The Market Leader in Globalization Technology –Pioneers in visual translation environments –Solutions for major platforms & programming.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Globalization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation.
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.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
ASP.NET OPTIMIZATION. Why Optimize? $$$ Whether you build applications for customers or not, enhanced applications save money.
Complex Scripts* in Internet Explorer 5.0 *and Multilingual text F. Avery Bishop Senior Program Manager Microsoft Corporation.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 14 Globalization Support in the Database.
1 Chapter 12: Form Builder Objects and Flexible Code.
1 Chapter 2: Working with Data in a Project 2.1 Introduction to Tabular Data 2.2 Accessing Local Data 2.3 Accessing Remote Data 2.4 Importing Text Files.
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.
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.
Week 7 Lecture 2 Globalization Support in the Database.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Three Using Variables and Constants.
ASP.NET User Controls. User Controls In addition to using Web server controls in your ASP.NET Web pages, you can create your own custom, reusable controls.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Programming with Microsoft Visual Basic th Edition
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Internationalization Andres Käver, IT Kolledž 2015.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
Preface IIntroduction Course Objectives I-2 Course Content I-3 1Introduction to Oracle Reports Developer Objectives 1-2 Business Intelligence 1-3 Enterprise.
7/23/2016 CSC 325 Advanced Programming Techniques Localization Slide #1 1 Localization Mikhail Brikman.
Creating Consistent Looking Websites
Creating Database Objects
ASP.NET Forms.
Metropolia 2013 C# programming and .NET framework
Globalization support in ASP.NET
Course Name: QTP Trainer: Laxmi Duration: 25 Hrs Session: Daily 1 Hr.
Variables and Arithmetic Operations
Programming with Microsoft Visual Basic 2008 Fourth Edition
Creating Database Objects
Presentation transcript:

Internationalization in ASP.NET 2.0

SQL Server 2005 – Data Columns Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations nchar nchar nvarchar nvarchar nvarchar(max) nvarchar(max) ntext ntext Catalog view sys.types reports length in bytes, not characters Catalog view sys.types reports length in bytes, not characters Substitute: ASCII() and CHAR() with: UNICODE() and NCHAR() Substitute: ASCII() and CHAR() with: UNICODE() and NCHAR() Define variables and parameters of Stored Procedure and triggers in Unicode Define variables and parameters of Stored Procedure and triggers in Unicode Prefix Unicode string constants with the letter “N” Prefix Unicode string constants with the letter “N”

Establish the User’s preferred “culture”

Culture Description of a language, and OPTIONALLY a region Description of a language, and OPTIONALLY a region System.Globalization.CultureInfo class System.Globalization.CultureInfo class languagecode2[-country/regioncode2[- script]] languagecode2[-country/regioncode2[- script]] Examples: en represents “neutral English” en-GB represents UK English Examples: en represents “neutral English” en-GB represents UK English CultureInfo object CultureInfo object Invariant:“”absence of culture (may be English) Invariant:“”absence of culture (may be English) Neutral“en”Language – NOT specific to a particular region Neutral“en”Language – NOT specific to a particular region Specific“en-GB” Language in a specific region, and region info, Specific“en-GB” Language in a specific region, and region info,

Default International behavior Default internationalization behavior is determined by: CurrentCulture – must be a SPECIFIC culture: default culture for System.Globalization – affects culture specific formatting (date/time, number,currency, … AND display of Calendar control) CurrentUICulture – Can be neutral or specific culture: default culture used by ResourceManager

Setting the Culture Web.config Web.config Or, Or, Page Page Automatic (browser’s first requested culture) with default: Automatic (browser’s first requested culture) with default: Programmatically: Programmatically: Analyze complete list of browsers culture requests Analyze complete list of browsers culture requests Based upon setting in the User’s Profile Based upon setting in the User’s Profile

Set Culture – reviewing all browser requests – CODE Sample Protected Overloads Overrides Sub InitializeCulture() If Request.UserLanguages IsNot Nothing AndAlso Request.UserLanguages.GetLength(0) > 0 Then If Request.UserLanguages IsNot Nothing AndAlso Request.UserLanguages.GetLength(0) > 0 Then Dim ct As New CultureInfo(Request.UserLanguages(0)) Dim ct As New CultureInfo(Request.UserLanguages(0)) If ct IsNot Nothing Then If ct IsNot Nothing Then Thread.CurrentThread.CurrentUICulture = ct Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ct.Name) Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ct.Name) End If End If End Sub

Resource Code

Resource code Managers ASP.NET – Built-in: System.Resources.ResourceManager ASP.NET – Built-in: System.Resources.ResourceManager Uses standard.resx format Uses standard.resx format Easily handled by localization firmsEasily handled by localization firms Directly supported in VS 2005 Directly supported in VS 2005 Built-in tool to generate.resx files from non-localized ASP.NET project Built-in tool to generate.resx files from non-localized ASP.NET project Cached – good performance Cached – good performance Custom resource managers Custom resource managers Directly use SQL Server Directly use SQL Server Slower performance Slower performance

Creating Resource Files – VS 2005 Tool Visual Studio 2005 tool: Generate Local Resources Generates resource file for a particular page -- from Design view – Tools > Generate Local Resoruces Generates resource file for a particular page -- from Design view – Tools > Generate Local Resoruces Automatically creates.resx file that includes all properties marked: Localizable(true) Automatically creates.resx file that includes all properties marked: Localizable(true) By default, most Webcontrols’: Text, Title, ToolTip By default, most Webcontrols’: Text, Title, ToolTip NOT HTLM controls, except: HtmlAnchor, HtmlImage HtmlInputImage, HtmlTitle NOT HTLM controls, except: HtmlAnchor, HtmlImage HtmlInputImage, HtmlTitle Automatically modifies the page source Automatically modifies the page source Does NOT work with raw HTML, e.g.: text can substitute Localize control Does NOT work with raw HTML, e.g.: text can substitute Localize control

Resource File Hierarchy The Generate Local Resource tool only creates the default page resource files. You must copy the default resource files and rename then to create the language resource hierarchy.

Generate Local Resources Generate Local Resources – Page Source Example code, before using tool : after using tool : after using tool : Page Language=“vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>

Generate Local Resources Generate Local Resources – Example code – BEFORE using tool : Generate Local Resources – Example code – BEFORE using tool : <table><tr> <asp:Label ID="Label1" runat="server" Text="User name "> Text="User name "> </asp:TextBox></td></tr></table>

Generate Local Resources Generate Local Resources – Example code, after using tool : <asp:Label ID="Label1" runat="server" Text="User Name" meta:resourcekey="Label1Resource1"></asp:Label></td> <asp:TextBox ID="TextBox1" runat="server" meta:resourcekey="TextBox1Resource1"></asp:TextBox></td>

Resource Code Generation Demo

Add App_GlobalResources Folder & App_LocalResources Folder Adding Global Resource File under App_GlobalResources Folder Adding Local Resource File under App_LocalResources Folder Note: While creating resource file, you should name resource file with filename.aspx.cultercode.resx Adding Global Resource File under App_GlobalResources Folder Adding Local Resource File under App_LocalResources Folder Note: While creating resource file, you should name resource file with filename.aspx.cultercode.resx

Generate Local Resources Generate Local Resources – Example Resource file :

Generate Local Resources Generate Local Resources – Original TEXT attribute is retainedOriginal TEXT attribute is retained Not used at RuntimeNot used at Runtime Shown at design timeShown at design time Property Windows - shown with pink icon:Property Windows - shown with pink icon:

Preventing localization When using the Generate Local Resources tool Can prevent a control from being included in Generate Local Resources: <asp:Label ID="Label1" runat="server" Can prevent a control from being included in Generate Local Resources: <asp:Label ID="Label1" runat="server" Meta:localize=“false” Text="User name ">

Localize control Generate Local Resource tool Does NOT work with static text, e.g.: This is an example. Generate Local Resource tool Does NOT work with static text, e.g.: This is an example. Can substitute Localize control (derived from Literal), but must contain ONLY static text (no ASP.NET controls) This is an example. Generate Local Resources will transform this to: meta:resourcekey=“locEx” Text=“This is an example.”> Can substitute Localize control (derived from Literal), but must contain ONLY static text (no ASP.NET controls) This is an example. Generate Local Resources will transform this to: meta:resourcekey=“locEx” Text=“This is an example.”>

Explicit Expressions Generate Local Resource tool – generates IMPLICIT expressions for controls with properties marked internally as “Localizable(true)” Explicit Expressions – useful for binding resources to ANY property … such as color, or ImageURL of ImageControl - use in HTML Attributes - use in HTML Attributes

Explicit Expressions – cont’d Explicit Expressions Syntax: " Syntax: " If resource-file is not specified, then looks for resource-key in local resource If resource-file is not specified, then looks for resource-key in local resource Cannot combine: Explicit resource expression for a local resource and Implicit resource expression within same control Cannot combine: Explicit resource expression for a local resource and Implicit resource expression within same control Can combine: Explicit resource expression for a GLOBAL resource and Implicit resource expression within same control Can combine: Explicit resource expression for a GLOBAL resource and Implicit resource expression within same control

Global Resources Reduces duplication All pages may share access to the same set of resources Reduces duplication All pages may share access to the same set of resources Necessary for Explicit resources where in control that also uses Implicit resources Necessary for Explicit resources where in control that also uses Implicit resources Compiled into a strongly typed class Compiled into a strongly typed class MUST be in folder: App_GlobalResources MUST be in folder: App_GlobalResources MUST use explicit resource references MUST use explicit resource references

Programmatic Resource Access Global Resources Can use compiled classname labMessage.Text = Resources.GlobalColors.WarningColor Can use compiled classname labMessage.Text = Resources.GlobalColors.WarningColor Local Resources User the GetLocalResourceObject labMessage.Text = me.GetLocalResourceObject( “PageResources1.title”) User the GetLocalResourceObject labMessage.Text = me.GetLocalResourceObject( “PageResources1.title”)

Using Assemblies The ResourceManager class allows the user to access and control resources stored in the main assembly or in resource satellite assemblies The ResourceManager class allows the user to access and control resources stored in the main assembly or in resource satellite assemblies The Resource File Generator (Resgen.exe) converts.txt files and.resx (XML-based resource format) files to common language runtime binary.resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies. The Resource File Generator (Resgen.exe) converts.txt files and.resx (XML-based resource format) files to common language runtime binary.resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies.

Using Text files resource.fr-FR.txt - which contains the below French text. resource.fr-FR.txt - which contains the below French text.

visual studio command prompt Now open the visual studio command prompt and run the resgen.exe with.txt file as parameter as shown in image below. Now open the visual studio command prompt and run the resgen.exe with.txt file as parameter as shown in image below.

Code to Access Assemblies 'Read the rsources files 'Read the rsources files Dim strResourcesPath As String = Server.MapPath("bin") Dim strResourcesPath As String = Server.MapPath("bin") Dim rm As ResourceManager = ResourceManager.CreateFileBasedResourc eManager("resource.fr-FR", strResourcesPath, Nothing) Dim rm As ResourceManager = ResourceManager.CreateFileBasedResourc eManager("resource.fr-FR", strResourcesPath, Nothing) lblwelcome.Text = rm.GetString("0006") + ", " + rm.GetString("0007") Button1.Text = rm.GetString("0008") Button1.Text = rm.GetString("0008")

Numbers/Currency Numberic.ToString Culture formatted using NumberFormatInfo class Culture formatted using NumberFormatInfo class Can be created for Specific or Invariant culture, but NOT created for a neutral culture Can be created for Specific or Invariant culture, but NOT created for a neutral culture Default set by CurrentCulture’s NumberFormat Property Default set by CurrentCulture’s NumberFormat Property Standard number format Specifiers Standard number format Specifiers Uses NumberFormatInfo class: Uses NumberFormatInfo class: c, CCurrencyf, FFixed Point n, NNumberp, P Percent Does NOT use NumberFormatInfo class: Does NOT use NumberFormatInfo class: d, DDecimale, EExponential x, XHexadecimal g, GGeneralr, RRound-trip Can specify a particular culture Can specify a particular culture Val.ToString(“N”, new CultureInfo(“fr-FR”)) Val.ToString(“N”, new CultureInfo(“fr-FR”))

DateTime - Output DateTime.ToString method Culture formatted using DateTimeFormatInfo class Culture formatted using DateTimeFormatInfo class Can be created for Specific or Invariant culture, but NOT created for a neutral culture Can be created for Specific or Invariant culture, but NOT created for a neutral culture Default set by CurrentCulture’s DateTimeFormat Property Default set by CurrentCulture’s DateTimeFormat Property Uses CurrentCulture by default: Uses CurrentCulture by default: ToString()ToShortDateString()ToLongDateString() ToShortTimeString()ToLongTimeString() Specify particular culture: Specify particular culture:ToString(string) ToString(string, IFormatProvider)