Think Global! Custom Cultures and International Data Matt Ayers Program Manager Windows...

Preview:

Citation preview

Think Global! Think Global! Custom Cultures and Custom Cultures and International Data International Data

Matt AyersMatt AyersProgram ManagerProgram Manager

Windows InternationalWindows International

Achim RuoppAchim RuoppProgram ManagerProgram Manager

Developer GlobalizationDeveloper Globalization

Microsoft CorporationMicrosoft Corporation

The Global Software MarketThe Global Software MarketGlobal PC Market in 2010?Global PC Market in 2010?

Source: Source: http://news.com.com/Global+PC+market+to+double+by+2010/2100-1042_3-5490500.html

0

200

400

600

800

1000

1200

1400

2004 2010

Number of PCs in

millions

Emerging Markets

US, Europe, Asia-PacificCurrent Install Base

The Global Software MarketThe Global Software MarketLanguages in FloridaLanguages in Florida

Source: U.S. Census 2000 (Source: U.S. Census 2000 (http://quickfacts.census.gov/qfd/states/12000.html)

English spoken at

home77%

Other language

sometimes or always spoken at

home23%

Reasons to Go GlobalReasons to Go Global

Increasing marketIncreasing market

Multinational enterprisesMultinational enterprises

FlexibilityFlexibilityWeb-based applications or distributionWeb-based applications or distribution

International data exchangeInternational data exchange

InternationalizationInternationalizationGlobal user expectationsGlobal user expectations

World ReadyWorld Ready

LocalizedLocalized

Text and data are stored in aText and data are stored in aculture-neutral formatculture-neutral format

Market SpecificMarket Specific

The User Interface is translatedThe User Interface is translated

Features are added that areFeatures are added that arespecific to a given culturespecific to a given culture

One Code BaseOne Code Base

.NET Framework.NET FrameworkInternationalizationInternationalization

Built-in data and functionality for many Built-in data and functionality for many different culturesdifferent cultures

Best practicesBest practices

How to exchange dataHow to exchange data

How to customize and extend .Net How to customize and extend .Net Framework culturesFramework cultures

Quick QuizQuick Quiz

In what month does the following day fall?In what month does the following day fall?

03/01/200503/01/2005a.a. March?March?

b.b. January?January?

c.c. None of the above.None of the above.

d.d. Not enough info.Not enough info.

Formatting Dates andFormatting Dates andCulture ExplorerCulture Explorer

Achim RuoppAchim RuoppInternational Program ManagerInternational Program ManagerDeveloper GlobalizationDeveloper Globalization

Culture-Dependent DataCulture-Dependent DataAPI supportedAPI supported

Numeric formatsNumeric formatsCurrenciesCurrenciesMeasurement systemsMeasurement systemsDate/Time formatsDate/Time formatsTime Zones (limited)Time Zones (limited)CalendarsCalendarsCharacter encodingCharacter encodingCapitalizationCapitalizationCollation (Sorting)Collation (Sorting)Word breaking (limited)Word breaking (limited)Character output/fontsCharacter output/fontsCharacter input/Character input/keyboard layoutskeyboard layoutsBi-Directional layoutBi-Directional layoutMulti-lingual UIMulti-lingual UI

not API supportednot API supportedPaper sizesPaper sizesAddress formatsAddress formatsPhone number formatsPhone number formatsMeasurement conversionMeasurement conversionExchange ratesExchange ratesTaxationTaxationCompliance with local Compliance with local lawslawsBusiness conventionsBusiness conventions

CultureInfo and RegionInfoCultureInfo and RegionInfo

In the .Net Framework, culture-In the .Net Framework, culture-dependent data is managed by the dependent data is managed by the CultureInfo and RegionInfo classesCultureInfo and RegionInfo classes

CultureInfo is used toCultureInfo is used toFormat dataFormat data

Load resourcesLoad resources

Set rules for comparing stringsSet rules for comparing strings

Thread settingsThread settingsCurrentCultureCurrentCulture

CurrentUICultureCurrentUICulture

Framework CulturesFramework Cultures

Over 200 cultures will ship in .Net Over 200 cultures will ship in .Net Framework 2.0Framework 2.0

Two types of culturesTwo types of culturesSpecificSpecific

Identified by language and regionIdentified by language and region

NeutralNeutralLanguage only Language only

Only used for resource loadingOnly used for resource loading

Handling Different Data Handling Different Data Formats in one Formats in one Code BaseCode Base

Formatting PrinciplesFormatting Principles

Business Logic/Data LayerBusiness Logic/Data Layer

1. Store and transmit the data in culture-invariant format1. Store and transmit the data in culture-invariant format2.2. Store as binary data where possibleStore as binary data where possible3. Store additional meta information where necessary3. Store additional meta information where necessary

User Interface LayerUser Interface Layer

1. Parse and display data in format the user expects1. Parse and display data in format the user expects2. Respect user preferences wherever possible2. Respect user preferences wherever possible

Formatting and ParsingFormatting and Parsing

FormattingFormattingStandard formatting charactersStandard formatting characters

Custom formatting charactersCustom formatting characters

ParsingParsingConfigurable with stylesConfigurable with styles

TryParse – no conversion exceptionsTryParse – no conversion exceptions

ParseExact for date/time valuesParseExact for date/time values

Type ObjectType ObjectCulture-appropriateCulture-appropriate

StringString

FormattingFormatting

ParsingParsing

NumbersNumbersNumeric FormatsNumeric Formats

Store as binary data type if possibleStore as binary data type if possibleInteger, decimal, floating-pointInteger, decimal, floating-point

Invariant storage as textInvariant storage as textFormat using CultureInfo.InvariantCultureFormat using CultureInfo.InvariantCulture

Use standard format character “R” (reversible) Use standard format character “R” (reversible) for floating point numbers for floating point numbers

CultureCulture FormatFormat ResultResult

en-USen-US NN 123,456.78123,456.78

fr-FRfr-FR NN 123 456,78123 456,78

hi-INhi-IN NN 1,23,456.781,23,456.78

"" (invariant)"" (invariant) RR 123456.78123456.78

NumbersNumbersNon-Arabic NumeralsNon-Arabic Numerals

Not supported by regular formatting and Not supported by regular formatting and parsing yetparsing yet

Use new functions in CharUnicodeInfoUse new functions in CharUnicodeInfoGetDecimalDigitValueGetDecimalDigitValue

GetNumericValueGetNumericValue

GetDigitValueGetDigitValue

Arabic-IndicArabic-Indic ٤٣٢١٤٣٢١ 12341234IdeographicIdeographic 〧〥〧〥 7575Number symbolsNumber symbols ¼¼ 0.250.25……

NumbersNumbersCurrenciesCurrencies

Preferably store as decimal with meta dataPreferably store as decimal with meta dataCultureCulture

DateTimeDateTime

Use 3Use 3rdrd party service for conversion party service for conversion

When storing as text use invariant cultureWhen storing as text use invariant cultureReversible text floating-point formatReversible text floating-point format

Currency text format: ¤1,000,000.23Currency text format: ¤1,000,000.23

decimal dec = decimal.Parse("$1000000.23", decimal dec = decimal.Parse("$1000000.23", NumberStyles.Currency,CultureInfo.CurrentCulture);NumberStyles.Currency,CultureInfo.CurrentCulture);System.Console.WriteLine("{0:C}", dec);System.Console.WriteLine("{0:C}", dec);

Output: $1,000,000.23Output: $1,000,000.23

NumbersNumbersMeasurement SystemsMeasurement Systems

Dates and TimesDates and TimesFormatsFormats

Dates – short date formatDates – short date format03/01/2005 in the United States03/01/2005 in the United States

01/03/2005 in Ireland01/03/2005 in Ireland

01.03.2005 in Russia01.03.2005 in Russia

2005-03-01 in Korea2005-03-01 in Korea

Times – short time formatTimes – short time format2:30 PM in the United States2:30 PM in the United States

14:30 in Japan14:30 in Japan

오전 오전 2:30 in Korea2:30 in Korea

Dates and TimesDates and TimesWhat is a DateTime object?What is a DateTime object?

Number of ticks (100 nanosecond units) Number of ticks (100 nanosecond units) since January 1, 0001 A.D. (Gregorian since January 1, 0001 A.D. (Gregorian calendar)calendar)Time Zone – Local vs. UTCTime Zone – Local vs. UTC

v1.x: No information about if DateTime is Local or v1.x: No information about if DateTime is Local or UTCUTCv2.0: Information intrinsic/definablev2.0: Information intrinsic/definableNo possibility yet to convert from one time zone No possibility yet to convert from one time zone to the otherto the otherUse UTC forUse UTC for

ArithmeticArithmeticStorageStorageTransmissionTransmission

Daylight saving timeDaylight saving time

Dates and TimesDates and TimesDateTime Formatting/ParsingDateTime Formatting/Parsing

Controlled by Controlled by DateTimeFormatInfo DateTimeFormatInfo

CalendarCalendarGregorian calendar is default for DateTimeGregorian calendar is default for DateTime

Invariant text formatsInvariant text formatsR or r (RFC1123)R or r (RFC1123)

Thu, 09 Jun 2005 20:30:00 GMTThu, 09 Jun 2005 20:30:00 GMT

s (ISO 8601)s (ISO 8601)2005-06-09T13:30:002005-06-09T13:30:00

yyyy-MM-ddTHH:mm:sszzzzzyyyy-MM-ddTHH:mm:sszzzzz (XML) (XML)2005-06-09T13:30:00-07:002005-06-09T13:30:00-07:00

Sorting and Comparing Sorting and Comparing TextText

Achim RuoppAchim RuoppInternational Program ManagerInternational Program ManagerDeveloper GlobalizationDeveloper Globalization

TextTextRepresentationRepresentation

Unicode (UTF-16) is data type for textUnicode (UTF-16) is data type for text

““Parsing” textParsing” textDeal with strings wherever possibleDeal with strings wherever possible

Character processing - text elementsCharacter processing - text elementsCombining charactersCombining characters

é = e + Ré = e + R

Unicode surrogate pairsUnicode surrogate pairsCombination of two 16-bit values to identify characterCombination of two 16-bit values to identify character

Improved support for processing text elements Improved support for processing text elements in v2.0in v2.0

Unicode Standard Normalization available Unicode Standard Normalization available in v2.0in v2.0

TextTextSorting and ComparisonSorting and Comparison

Comparison just a special case of Comparison just a special case of sortingsorting

For culture-appropriate comparison For culture-appropriate comparison useuse

StringComparison.CurrentCultureStringComparison.CurrentCulture

For culture-agnostic comparison useFor culture-agnostic comparison useStringComparison.OrdinalStringComparison.Ordinal

StringComparison.OrdinalIgnoreCaseStringComparison.OrdinalIgnoreCase

ToUpperInvariant for upper casingToUpperInvariant for upper casing

More performantMore performant

Less likely to change over timeLess likely to change over time

Verifying globalization Verifying globalization using FxCopusing FxCop

Achim RuoppAchim RuoppInternational Program ManagerInternational Program ManagerDeveloper GlobalizationDeveloper Globalization

Verification using FxCop Verification using FxCop

FxCop – a static code analysis toolFxCop – a static code analysis toolDownloadable from GotDotNet websiteDownloadable from GotDotNet website

Visual Studio Team Developer: full versionVisual Studio Team Developer: full version

Contains rules for checkingContains rules for checkingGlobalizationGlobalization

LocalizabilityLocalizability

Extending the FrameworkExtending the Framework

Extending the FrameworkExtending the Framework

Over 6 billion people on the planet, Over 6 billion people on the planet, even 200 cultures just isn’t enougheven 200 cultures just isn’t enough

You can expand cultures throughYou can expand cultures throughUser overrides User overrides

Custom culturesCustom cultures

Windows Data Derived culturesWindows Data Derived cultures

User OverridesUser Overrides

Per-user setting affecting the current Per-user setting affecting the current default culture.default culture.

Set using regional options in WindowsSet using regional options in Windows

Limited set of customizable fieldsLimited set of customizable fields

Only in effect for CurrentCulture w/ Only in effect for CurrentCulture w/ UseUserOverride = TrueUseUserOverride = True

Available in all versions of the .Net Available in all versions of the .Net FrameworkFramework

Custom culturesCustom cultures

Are installed for all users on a machineAre installed for all users on a machine

Allow you to set more fields than user Allow you to set more fields than user overridesoverrides

Can either replace a culture that ships Can either replace a culture that ships with .Net Framework or add to the set with .Net Framework or add to the set of Framework culturesof Framework cultures

Creating a custom cultureCreating a custom culture

The old way – override CultureInfoThe old way – override CultureInfoCumbersomeCumbersome

Only works for a specific applicationOnly works for a specific application

Difficult to maintainDifficult to maintain

Some APIs clone before usingSome APIs clone before using

Creating a custom cultureCreating a custom culture

The new way – use the The new way – use the CultureAndRegionInfoBuilder (CARIB)CultureAndRegionInfoBuilder (CARIB)

PortablePortable

Works for all users and all applicationsWorks for all users and all applications

Creates a CultureInfo object that is the Creates a CultureInfo object that is the same as those that ship with the same as those that ship with the FrameworkFramework

Supplemental CulturesSupplemental Cultures

Use supplemental cultures to expand Use supplemental cultures to expand the set of cultures available in the .Net the set of cultures available in the .Net frameworkframework

Some limitationsSome limitationsSingle custom LCIDSingle custom LCID

No custom collations or calendarsNo custom collations or calendars

Display name is same as native nameDisplay name is same as native name

Create A New CultureCreate A New CultureSpanish in the U.S.Spanish in the U.S.

Create A New CultureCreate A New CultureSpanish in the U.S.Spanish in the U.S.

// Set the native name and DateTimeFormat // Set the native name and DateTimeFormat information to Spanishinformation to Spanish

carib.CultureNativeName = carib.CultureNativeName = “Español (Estados-Unidos)”;“Español (Estados-Unidos)”;

carib.GregorianDateTimeFormat = carib.GregorianDateTimeFormat = ciES.DateTimeFormat;ciES.DateTimeFormat;

// Keep the United States’ time pattern// Keep the United States’ time patterncarib.GregorianDateTimeFormat.LongTimePattern = carib.GregorianDateTimeFormat.LongTimePattern =

ciUS.DateTimeFormat.LongTimePattern;ciUS.DateTimeFormat.LongTimePattern;

[...][...]

Create A New CultureCreate A New CultureSpanish in the U.S.Spanish in the U.S.

// Deploy the Culture on this machine// Deploy the Culture on this machinecarib.Register();carib.Register();

// Instantiate a new CultureInfo from our // Instantiate a new CultureInfo from our new datanew data

CultureInfo ci = new CultureInfo("es-US");CultureInfo ci = new CultureInfo("es-US");

Create the Supplemental Create the Supplemental Culture es-USCulture es-US

Matt AyersMatt AyersProgram ManagerProgram ManagerWindows InternationalWindows International

Replacement CulturesReplacement Cultures

Important Note!Important Note!

If an admin replaces a culture, If an admin replaces a culture, applications applications can notcan not access the access the Microsoft definitionsMicrosoft definitions

Use CultureInfo.CultureTypes property Use CultureInfo.CultureTypes property to determine if a CultureInfo represents to determine if a CultureInfo represents a replacement culturea replacement culture

If ((ci.CultureTypes & CultureTypes. If ((ci.CultureTypes & CultureTypes. ReplacementCultures) != 0) {…}ReplacementCultures) != 0) {…}

Windows Data Derived Windows Data Derived CulturesCultures

Used when a culture does not exist in Used when a culture does not exist in the .Net Framework but is available as a the .Net Framework but is available as a Windows LocaleWindows Locale

For example: zu-ZA, cy-GB, mt-MTFor example: zu-ZA, cy-GB, mt-MT

The .Net Framework uses data from the The .Net Framework uses data from the Windows Locale to create a CultureInfoWindows Locale to create a CultureInfo

Interoperability & MigrationInteroperability & MigrationNon-Microsoft PlatformsNon-Microsoft Platforms

Use CultureAndRegionInfoBuilder.Save Use CultureAndRegionInfoBuilder.Save to generate LDML filesto generate LDML files

Use CultureAndRegionInfoBuilder.Load Use CultureAndRegionInfoBuilder.Load to read LDML filesto read LDML files

Note that most non-Microsoft LDML Note that most non-Microsoft LDML files will require some tweaking before files will require some tweaking before calling Register()calling Register()

ConclusionConclusion

To ship a global-ready application, you To ship a global-ready application, you must use data-formatting tailored to must use data-formatting tailored to your target marketyour target market

With some planning, you can make a With some planning, you can make a global-ready application from the global-ready application from the beginning and save time and money beginning and save time and money down the roaddown the road

Net Framework 2.0 allows users to Net Framework 2.0 allows users to expand the set of available formatsexpand the set of available formats

ResourcesResources

Resource 1: Microsoft GlobalDev Website

Resource 2: Developing International Software 2Dr. International(available at the TechEd store)

Resource 3: Globalization & Localization in Visual Studio

Resource 4: Send mail to Dr. International

Resource 5: Internationalization newsgroup

Resource 6: Globalization Handbook for theMicrosoft .Net PlatformBill Hall

Resource 7: Blogs Sorting it All OutTales from the Crossroads

ResourcesResourcesTech-Ed 2005 International Break-out SessionsTech-Ed 2005 International Break-out Sessions

TitleTitleCodeCode

ASP.NET 2.0: Going GlobalASP.NET 2.0: Going Global Gets Easier! New Localization Features in Gets Easier! New Localization Features in ASP.NET 2.0ASP.NET 2.0

WEB326WEB326

Deploying Office 2003Deploying Office 2003 in a Multilingual Environment in a Multilingual EnvironmentDSK345DSK345

Deploying Windows XPDeploying Windows XP in a Multilingual Environment in a Multilingual EnvironmentDSK350DSK350

Databases for the World:Databases for the World: Best Practices for Search in Multilingual Data Best Practices for Search in Multilingual Data Sets Using SQL Server Collation for Sorting and IndexingSets Using SQL Server Collation for Sorting and Indexing

DBA319DBA319

Microsoft Business SolutionsMicrosoft Business Solutions––Axapta:Axapta: A Truly Global Business Application A Truly Global Business ApplicationBAP347BAP347

Supporting East Asian LanguagesSupporting East Asian Languages in Global Exchange Deployments in Global Exchange DeploymentsMSG369MSG369

.NET Framework: Think Global!.NET Framework: Think Global! Custom Cultures and International Data Custom Cultures and International DataDEV323DEV323

Databases for the World:Databases for the World: Designing Multilingual Databases Using SQL Designing Multilingual Databases Using SQL Server 2005Server 2005

DAT290DAT290

Planning a Global Release:Planning a Global Release: Many countries, Many Languages, One Process Many countries, Many Languages, One ProcessARC303ARC303

ResourcesResourcesTech-Ed 2005 International Cabana TalksTech-Ed 2005 International Cabana Talks

Dr. International’s ClinicDr. International’s Clinic

Booth in the Community Cabana International Experts available all week long

TitleTitleCodeCode

Custom Cultures in Whidbey: Custom Cultures in Whidbey: An In-Depth DiscussionAn In-Depth DiscussionDEVC21DEVC21

Advanced Localization ArchitectureAdvanced Localization ArchitectureDEVC19DEVC19

Windows XP MUI:Windows XP MUI: Keeping it Localized & Secure Keeping it Localized & SecureDSKC07DSKC07

Meet the Speakers From ARC303: Meet the Speakers From ARC303: Planning a Global ReleasePlanning a Global ReleaseARCC04ARCC04

Your FeedbackYour Feedbackis Important!is Important!

Please Fill Out a Survey forPlease Fill Out a Survey forThis Session on CommNetThis Session on CommNet

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Resources (URL format)Resources (URL format)

Resource 1: http://www.microsoft.com/globaldev

Resource 2: Developing International Software 2Dr. International

Resource 3: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vxoriGlobalizationLocalizationNamespaces.asp

Resource 4:mailto:drintl@microsoft.com

Resource 5: news:microsoft.public.dotnet.internationalization

Resource 6: Globalization Handbook for theMicrosoft .Net PlatformBill Hall

Resource 7: http://blogs.msdn.com/michkaphttp://blogs.msdn.com/achimr

Recommended