Download presentation
Presentation is loading. Please wait.
Published byAlban Young Modified over 9 years ago
1
DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge
2
Christian Nagel Trainings, Consulting, Coaching Software Architect, Developer http://www.christiannagel.com Global Knowledge – http://www.globalknowledge.at http://www.globalknowledge.at
3
Agenda Globalization and Localization Resource model Localization using Windows Forms Localization with ASP.NET Web Applications Demos
4
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
5
Unicode Issues 64K characters is not enough Chinese has over 80,000 characters Represented by supplemental characters (surrogate pairs) Supporting these is a requirement for EA markets Problems: Searching Composition | Decomposition
6
Combining Characters Some characters can be expressed: As pre-composed characters As base character + combining character(s) ǭǭ U+01EDU+01ED ̄̄ǫǫ U+01EBU+01EBU+0304U+0304 == == ̄̄ ̨ ̨ U+0328U+0328U+0304U+0304 oo U+006FU+006F
7
String Handling Use strings whenever possible (no individual characters) Rely on the StringInfo methods to handle surrogates and combining characters StringInfo::ParseCombiningCharacters StringInfo::GetTextEnumerator
8
System.Globalization Namespace Culture-aware string comparisons Date & Time formatting Numeric formatting Calendars
9
CultureInfo Invariant culture Culture-invariant default Neutral culture Based on language Resource only UI Culture only Specific culture Based on language and region Resource and Formatting specificsinvariant de de-AT de-CH de-DE de-LI de-LU en
10
Culture and UICulture CurrentUICulture Dependent on the operating system Can be set on Windows XP and Windows 2000 MUI CurrentCulture Picked up from GetUserDefaultLCID Control Panel | Regional Options Only specific cultures can be assigned
11
Invariant Culture CultureInfo.InvariantCulture Neither a neutral nor a specific culture Loosely associated with the English language Uses of the Invariant Culture Storing data Transferring data across the network For UI, prefer culture-sensitive formatting
12
Regions Class: RegionInfo IsMetric CurrencySymbol ISOCurrencySymbol
13
Culture-Aware Classes Calendar classes Gregorian, Hebrew, Hijiri, Japanese, Julian, Korean, Taiwin, Thai Buddhist DateTime, DateTimeFormatInfo NumberFormatInfo CompareInfo
14
Cultures and Regions Date/Time Formatting Number Formatting CultureInfo, RegionInfo demo demo
15
Setting the Culture Explicitely Culture of the Thread Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES"); Individual API string s = DateTime.Now.ToString("D", new CultureInfo("de-AT"));
16
Culture Specific Formatting: Text Output Any API wich takes a culture, or an IFormatProvider Default culture setting of the thread textBox1.Text = DateTime.Today.ToString("D"); textBox2.Text = floatNumber.ToString("N"); Specific culture setting textBox1.Text = DateTime.Today.ToString("D", new CultureInfo("es-ES")); textBox2.Text = floatNumber.ToString("N", new CultureInfo("de-AT"));
17
Culture Specific Formatting: Text Input Default culture setting for the thread string 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);
18
Setting the Culture with ASP.NET Applications Web Config File Page Directive Programmatically using IE Settings demo demo
19
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
20
Resource Fallback Resources and Cultures Main Assembly CodeCode Default resources (fallback)Default resources (fallback)Greeting=“Hello”Farewell=“Goodbye” Logo= Logo= French No codeNo code “fr” resources“fr” resources Greeting = “Bonjour” Farewell = “Au revoir” French (France) (fr-FR) No codeNo code “fr-FR” resources“fr-FR” resourcesGreeting=“Salut”
21
Resource Manager Provides access to culture-correct resources Sources File-based Resources Assemblies, Satellite Assemblies Custom Resource Readers (e.g. Database- access)
22
Resource Sources File-based Resources Don't use them with ASP.NET Applications (files are locked) Additional languages can be added easily Satellite Assemblies Resource-only language-specific assembly Custom ResourceReader Read from custom data stores
23
Using Resources with Windows Forms Applications Visual Studio.NET Designer Support Windows Resource Localization Editor demo demo
24
Localizing ASP.NET Applications Different Pages for Every Language Fast access More maintenance needed Satellite Assemblies Don't use resource files with ASP.NET! Custom Resource Reader Store localized resources in the database
25
Creating a Custom ResourceReader Read Resources from a Database for ASP.NET demo demo
26
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
27
Questions? Questions?
28
Ask The Experts Get Your Questions Answered Thursday 11:00-14:00 Friday 11:00-13:30
29
Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx http://www.ineta.org
30
Suggested Reading And Resources The tools you need to put technology to work! TITLEAvailable Today Developing International Software, Second 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
31
evaluations evaluations
32
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.