dev382 building international applications with the.net framework christian nagel microsoft regional...
Post on 02-Jan-2016
217 Views
Preview:
TRANSCRIPT
DEV382
Building International Applications with the .NET Framework
Christian NagelMicrosoft Regional DirectorGlobal Knowledge
Christian Nagel
Trainings, Consulting, Coaching
Software Architect, Developer
http://www.christiannagel.com
Global Knowledge – http://www.globalknowledge.at
Agenda
Globalization and Localization
Resource model
Localization using Windows Forms
Localization with ASP.NET Web Applications
Demos
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
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
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
String Handling
Use strings whenever possible (no individual characters)
Rely on the StringInfo methods to handle surrogates and combining characters
StringInfo::ParseCombiningCharacters
StringInfo::GetTextEnumerator
System.Globalization Namespace
Culture-aware string comparisons
Date & Time formatting
Numeric formatting
Calendars
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
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
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
Regions
Class: RegionInfoIsMetric
CurrencySymbol
ISOCurrencySymbol
Culture-Aware Classes
Calendar classesGregorian, Hebrew, Hijiri, Japanese, Julian, Korean, Taiwin, Thai Buddhist
DateTime, DateTimeFormatInfo
NumberFormatInfo
CompareInfo
Cultures and Regions
Date/Time Formatting
Number Formatting
CultureInfo, RegionInfo
demodemo
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"));
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"));
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);
Setting the Culture with ASP.NET Applications
Web Config File
Page Directive
Programmatically using IE Settings
demodemo
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
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”
Resource Manager
Provides access to culture-correct resources
SourcesFile-based Resources
Assemblies, Satellite Assemblies
Custom Resource Readers (e.g. Database-access)
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
Using Resources with Windows Forms Applications
Visual Studio .NET Designer Support
Windows Resource Localization Editor
demodemo
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
Creating a Custom ResourceReader
Read Resources from a Database for ASP.NET
demodemo
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
Questions?Questions?
Ask The ExpertsGet Your Questions Answered
Thursday 11:00-14:00
Friday11:00-13:30
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
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
evaluationsevaluations
© 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.
top related