dev382 building international applications with the.net framework christian nagel microsoft regional...

32
DEV382 Building International Applications with the .NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Upload: alban-young

Post on 02-Jan-2016

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

DEV382

Building International Applications with the .NET Framework

Christian NagelMicrosoft Regional DirectorGlobal Knowledge

Page 2: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Christian Nagel

Trainings, Consulting, Coaching

Software Architect, Developer

http://www.christiannagel.com

Global Knowledge – http://www.globalknowledge.at

Page 3: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Agenda

Globalization and Localization

Resource model

Localization using Windows Forms

Localization with ASP.NET Web Applications

Demos

Page 4: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Key Terms

Globalization (Internationalization)Create applications that support multiple cultures

Character encodings

Date, time, numeric, currency formats

Localization (Translation)Customize applicatons for a given culture

Resources

Page 5: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Unicode Issues

64K characters is not enoughChinese has over 80,000 charactersRepresented by supplemental characters (surrogate pairs)Supporting these is a requirement for EA markets

Problems:SearchingComposition | Decomposition

Page 6: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Combining Characters

Some characters can be expressed:As pre-composed characters

As base character + combining character(s)

ǭǭǭǭU+01EDU+01EDU+01EDU+01ED

0̄̄0 ̄0̄0 ǫǫǫǫU+01EBU+01EBU+01EBU+01EB U+0304U+0304U+0304U+0304

====

==== 0̄̄0 ̄0̄0 4 4 4 4 U+0328U+0328U+0328U+0328 U+0304U+0304U+0304U+0304

ooooU+006FU+006FU+006FU+006F

Page 7: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

String Handling

Use strings whenever possible (no individual characters)

Rely on the StringInfo methods to handle surrogates and combining characters

StringInfo::ParseCombiningCharacters

StringInfo::GetTextEnumerator

Page 8: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

System.Globalization Namespace

Culture-aware string comparisons

Date & Time formatting

Numeric formatting

Calendars

Page 9: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

CultureInfo

Invariant cultureCulture-invariant default

Neutral cultureBased on language

Resource only

UI Culture only

Specific cultureBased on language and region

Resource and Formatting specifics

invariantinvariant

dede

de-ATde-AT

de-CHde-CH

de-DEde-DE

de-LIde-LI

de-LUde-LU

enen

Page 10: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Culture and UICulture

CurrentUICultureDependent on the operating system

Can be set on Windows XP and Windows 2000 MUI

CurrentCulturePicked up from GetUserDefaultLCID

Control Panel | Regional Options

Only specific cultures can be assigned

Page 11: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Invariant Culture

CultureInfo.InvariantCultureNeither a neutral nor a specific culture

Loosely associated with the English language

Uses of the Invariant CultureStoring data

Transferring data across the network

For UI, prefer culture-sensitive formatting

Page 12: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Regions

Class: RegionInfoIsMetric

CurrencySymbol

ISOCurrencySymbol

Page 13: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Culture-Aware Classes

Calendar classesGregorian, Hebrew, Hijiri, Japanese, Julian, Korean, Taiwin, Thai Buddhist

DateTime, DateTimeFormatInfo

NumberFormatInfo

CompareInfo

Page 14: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Cultures and Regions

Date/Time Formatting

Number Formatting

CultureInfo, RegionInfo

demodemo

Page 15: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Setting the Culture Explicitely

Culture of the ThreadThread.CurrentThread.CurrentCulture =

new CultureInfo("fr-FR");

Thread.CurrentThread.CurrentUICulture =

new CultureInfo("es-ES");

Individual APIstring s = DateTime.Now.ToString("D",

new CultureInfo("de-AT"));

Page 16: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Culture Specific Formatting: Text Output

Any API wich takes a culture, or an IFormatProvider

Default culture setting of the threadtextBox1.Text = DateTime.Today.ToString("D");textBox2.Text = floatNumber.ToString("N");

Specific culture settingtextBox1.Text = DateTime.Today.ToString("D",

new CultureInfo("es-ES"));textBox2.Text = floatNumber.ToString("N",

new CultureInfo("de-AT"));

Page 17: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Culture Specific Formatting: Text Input

Default culture setting for the threadstring input = DateTime.Parse(textBox1.Text);

NumberStyles allows setting for decimal point, exponent, currency, whitespaces, hex numbers...

Double.TryParse(textBox2.Text, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, cultureInfo, out result);

Page 18: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Setting the Culture with ASP.NET Applications

Web Config File

Page Directive

Programmatically using IE Settings

demodemo

Page 19: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Resources

Localization of User Interfaces

XML or Binary Resource Files

Add texts, pictures, or any serializable object

Save resource information in Resource Files, Satellite Assemblies, or custom stores

Tools: resgen, Visual Studio .NET

Page 20: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Resource Fallback

Resources and Cultures

Main AssemblyMain Assembly•CodeCode•Default resources (fallback)Default resources (fallback)

Greeting=“Hello”Greeting=“Hello”Farewell=“Goodbye”Farewell=“Goodbye”Logo=<graphic data>Logo=<graphic data>

FrenchFrench•No codeNo code•““fr” resourcesfr” resources

Greeting = “Bonjour”Greeting = “Bonjour”Farewell = “Au revoir”Farewell = “Au revoir”

French (France) (fr-FR)French (France) (fr-FR)•No codeNo code•““fr-FR” resourcesfr-FR” resources

Greeting=“Salut”Greeting=“Salut”

Page 21: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Resource Manager

Provides access to culture-correct resources

SourcesFile-based Resources

Assemblies, Satellite Assemblies

Custom Resource Readers (e.g. Database-access)

Page 22: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Resource Sources

File-based ResourcesDon't use them with ASP.NET Applications (files are locked)

Additional languages can be added easily

Satellite AssembliesResource-only language-specific assembly

Custom ResourceReaderRead from custom data stores

Page 23: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Using Resources with Windows Forms Applications

Visual Studio .NET Designer Support

Windows Resource Localization Editor

demodemo

Page 24: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Localizing ASP.NET Applications

Different Pages for Every LanguageFast access

More maintenance needed

Satellite AssembliesDon't use resource files with ASP.NET!

Custom Resource ReaderStore localized resources in the database

Page 25: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Creating a Custom ResourceReader

Read Resources from a Database for ASP.NET

demodemo

Page 26: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Summary

The .NET Framework provides great support for localization and globalization

Use System.Globalization to globalize applications

Use System.Resources to localize applications

Similar .NET Framework support for Windows Forms and ASP.NET

Page 27: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Questions?Questions?

Page 28: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Ask The ExpertsGet Your Questions Answered

Thursday 11:00-14:00

Friday11:00-13:30

Page 29: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Community Resources

Community Resourceshttp://www.microsoft.com/communities/default.mspx

Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/

NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx

User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspxhttp://www.ineta.org

Page 30: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

Suggested Reading And Resources

The tools you need to put technology to work!The tools you need to put technology to work!

TITLETITLE AvailableAvailable

TodayTodayDeveloping International Software, Developing International Software, Second Edition: 0-7356-1583-7Second Edition: 0-7356-1583-7

Microsoft Press books are 20% off at the TechEd Bookstore

Also buy any TWO Microsoft Press books and get a FREE T-Shirt

Page 31: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

evaluationsevaluations

Page 32: DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge

© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.