Localization and Globalization in.NET Framework 2.0 ದೀ...

download Localization and Globalization in.NET Framework 2.0 ದೀ à® à´• गॠà²à¾ à°à±€ ISV Developer Evangelist Microsoft

of 75

  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of Localization and Globalization in.NET Framework 2.0 ದೀ...

  • Slide 1

Localization and Globalization in.NET Framework 2.0 ISV Developer Evangelist Microsoft Slide 2 The Global Software Market Global PC Market in 2010? Source: http://news.com.com/Global+PC+market+to+double+by+2010/2100-1042_3-5490500.html http://news.com.com/Global+PC+market+to+double+by+2010/2100-1042_3-5490500.html 0 200 400 600 800 1000 1200 1400 20042010 Number of PCs in millions Emerging Markets US, Europe, Asia- Pacific Current Install Base Slide 3 Reasons to Go Global Increasing market Local Indian market largely untapped! Multinational enterprises Flexibility Web-based applications or distribution International data exchange Slide 4 Internationalization Global user expectations World Ready Localized Text and data are stored in a culture-neutral format Market Specific The User Interface is translated Features are added that are specific to a given culture Slide 5 Definitions DefinitionsGlobalizationLocalizabilityLocalizationResources Slide 6 One Code Base Slide 7 .NET Framework Internationalization Built-in data and functionality for many different cultures Best practices How to exchange data How to customize and extend.Net Framework cultures Slide 8 Quick Quiz In what month does the following day fall? 03/01/2005 a. March? b. January? c. None of the above. d. Not enough info. Slide 9 Culture-Dependent Data API supported Numeric formats Currencies Measurement systems Date/Time formats Time Zones (limited) Calendars Character encoding Capitalization Collation (Sorting) Word breaking (limited) Character output/fonts Character input/ keyboard layouts Bi-Directional layout Multi-lingual UI not API supported Paper sizes Address formats Phone number formats Measurement conversion Exchange rates Taxation Compliance with local laws Business conventions Slide 10 CultureInfo and RegionInfo In the.Net Framework, culture- dependent data is managed by the CultureInfo and RegionInfo classes CultureInfo is used to Format data Load resources Set rules for comparing strings Thread settings CurrentCultureCurrentUICulture Slide 11 Culture Names RFC 1766 standard [-] languagecode2 two letter ISO-639-1 (lowercase) Country/regioncode two/three letter ISO 3166 (uppercase) Examples: kn-IN, ma-IN, ta-IN, hi-IN Slide 12 Types of Cultures Different Types Of Cultures Invariant Culture Neutral Cultures Specific Cultures Slide 13 Culture Tree Invariant Culture de (German Neutral Culture) de-AT (German- Austria) de-CH (German- Switzerland) de-DE (German- Germany) de-LI (German- Liechtenstein) de-LU (German- Luxembourg) en (English Neutral Culture) en-US (English- United States) en-GB (English- United Kingdom) Slide 14 Invariant Culture Culture Agnostic Happens to be associated with English Has no country/region Should be used for storing data in a culture independent way Should not be used for User Interface elements Slide 15 Invariant Culture VB.NET Dim ci As CultureInfo = CultureInfo.InvariantCulture C# CultureInfo ci = CultureInfo.InvariantCulture Slide 16 Neutral Culture Associated with a language not with country/region Can be used for UI related options Cannot be used for retrieving information such as date/time formatting Specified using format: Arabic ar Exceptions zh-CHT, zh-CHS Slide 17 Neutral Culture VB.NET Imports System.Globalization Dim ci As CultureInfo = New CultureInfo(fr) C# using System.Globalization; CultureInfo ci = new CultureInfo(fr); Slide 18 Specific Culture Associated with Language and a Country/Region fr Neutral Culture fr-FR Specific Culture Provides additional information about the date, time, currency and number formatting options Can be used wherever a Neutral culture is used, the opposite is not true Slide 19 Specific Culture VB.NET Imports System.Globalization Dim ci As CultureInfo = New CultureInfo(fr- FR) C# using System.Globalization; CultureInfo ci = new CultureInfo(fr-FR); Slide 20 Formatting Principles Business Logic/Data Layer 1. Store and transmit the data in culture-invariant format 2.Store as binary data where possible 3. Store additional meta information where necessary User Interface Layer 1. Parse and display data in format the user expects 2. Respect user preferences wherever possible Slide 21 Formatting and Parsing Formatting Standard formatting characters Custom formatting characters Parsing Configurable with styles TryParse no conversion exceptions ParseExact for date/time values Type Object Culture-appropriateString Formatting Parsing Slide 22 Number Factors affecting number formats The character used as the thousands separator US comma (1,025), Germany period (1.025), Sweden space (1 025) The character used as the decimal separator US period (1,025.7), Germany comma (1.025,7) The way negative numbers are displayed Negative sign can be used in the beginning or in the end of the number. The number can be displayed in parenthesis France -532, Netherlands 532-, US (532) Digit grouping This refers to the number of digits contained between each separator for all digit groups that appear to the left of the decimal separator United States: 123,456,789.00, India: 12,34,56,789.00 The placement of the percent sign (%) It can be written several ways: 98%, 98 %, 98 pct, %98 The shape of the numbers, or whether they have a one-to-one correspondence to the decimal set of digits (Indian languages dont have this issue yet) Slide 23 Numbers Numeric Formats Store as binary data type if possible Integer, decimal, floating-point Invariant storage as text Format using CultureInfo.InvariantCulture Use standard format character R (reversible) for floating point numbers CultureFormatResult en-USN123,456.78 fr-FRN123 456,78 hi-INN1,23,456.78 "" (invariant) R123456.78 Slide 24 Numbers Non-English Arabic-Indic Numerals Not supported by regular formatting and parsing yet Use new functions in CharUnicodeInfo GetDecimalDigitValueGetNumericValueGetDigitValue Arabic1234 Indic (Telugu/Hindi) / 12345 Ideographic75 Number symbols 0.25 Slide 25 Numbers Currencies Preferably store as decimal with meta data CultureDateTime Use 3 rd party service for conversion When storing as text use invariant culture Reversible text floating-point format Currency text format: 1,000,000.23 decimal dec = decimal.Parse("$1000000.23", NumberStyles.Currency,CultureInfo.CurrentCulture); System.Console.WriteLine("{0:C}", dec); Output: $1,000,000.23 Slide 26 CharUnicodeInfo Formatting Numbers Inventing NumberFormatInfo Slide 27 Numbers Measurement Systems RegionInfo.IsMetric Metric vs. Imperial System Depends on application target space Recommendation: metric Invariant culture has no associated RegionInfo Store/transfer system with number Specific culture name Custom indicator Slide 28 Dates and Times Formats Dates short date format 03/01/2005 in the United States 01/03/2005 in Ireland 01.03.2005 in Russia 2005-03-01 in Korea Times short time format 2:30 PM in the United States 14:30 in Japan 2:30 in Korea Slide 29 Dates and Times What is a DateTime object? Number of ticks (100 nanosecond units) since January 1, 0001 A.D. (Gregorian calendar) Time Zone Local vs. UTC v1.x: No information about if DateTime is Local or UTC v2.0: Information intrinsic/definable No possibility yet to convert from one time zone to the other Use UTC for ArithmeticStorageTransmission Daylight saving time Slide 30 Dates and Times DateTime Formatting/Parsing Controlled by DateTimeFormatInfoCalendar Gregorian calendar is default for DateTime Invariant text formats R or r (RFC1123) Thu, 09 Jun 2005 20:30:00 GMT s (ISO 8601) 2005-06-09T13:30:00 yyyy-MM-ddTHH:mm:sszzzzz (XML) 2005-06-09T13:30:00-07:00 Slide 31 Format Strings Format specifier Current culture Output den-US4/10/2001 den-NZ10/04/2001 dde-DE10.04.2001 Dhi-IN 10 2001 Den-US Tuesday, April 10, 2001 Ten-US 3:51:24 PM Tes-ES15:51:24 fen-US Tuesday, April 10, 2001 3:51 PM ffr-FR mardi 10 avril 2001 15:51 ren-US Tue, 10 Apr 2001 15:51:24 GMT rzh-SG sen-US2001-04-10T15:51:24 spt-BR2001-04-10T15:51:24 Slide 32 DateTime formatting Slide 33 Text Sorting and Comparison Comparison just a special case of sorting For culture-appropriate comparison use StringComparison.CurrentCulture For culture-agnostic comparison use StringComparison.OrdinalStringComparison.OrdinalIgnoreCase ToUpperInvariant for upper casing More performant Less likely to change over time Slide 34 Extending the Framework Over 6 billion people on the planet, even 200 cultures just isnt enough You can expand cultures through User overrides Custom cultures Windows Data Derived cultures Slide 35 User Overrides Per-user setting affecting the current default culture. Set using regional options in Windows Limited set of customizable fields Only in effect for CurrentCulture w/ UseUserOverride = True Available in all versions of the.Net Framework Slide 36 Custom cultures Are installed for all users on a machine Allow you to set more fields than user overrides Can either replace a culture that ships with.Net Framework or add to the set of Framework cultures Slide 37 Creating a custom culture The old way override CultureInfo Cumbersome Only works for a specific application Difficult to maintain Slide 38 Creating a custom culture The new way use the CultureAndRegionInfoBuilder (CARIB) Portable Works for all users and all applications Creates a CultureInfo object that is the same as those that ship with the Framework Slide 39 Supplemental Cultures Use supplemental cultures to expand the set of cultures available in the.Net framework Some limitations Only Admin can register new cultures No custom collations or calendars Slide 40 Replacement Cultures Used to replace an existing.Net Framework culture For example, en-US using a 24-hour clock Additional restrictions placed on replacement cultures: Cannot change the sorting Cannot change the LCID Must include the default calendar in available calendars Slide 41 Important Note! If an admin replaces a culture, applications can not acc