1 / 23

Globalization Support in Microsoft .NET Framework

Globalization Support in Microsoft .NET Framework . François Liger Program Manager Microsoft Corporation. What is .NET Framework?. .NET is Microsoft's platform for building, deploying, operating and integrating XML Web services. Rich XML, standard protocols, stateless

andrew
Télécharger la présentation

Globalization Support in Microsoft .NET Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Globalization Support in Microsoft .NET Framework François Liger Program Manager Microsoft Corporation

  2. What is .NET Framework? • .NET is Microsoft's platform for building, deploying, operating and integrating XML Web services. • Rich XML, standard protocols, stateless • Cross-language development • Common language runtime • Common type system for all languages • Rich runtime environment • Rich class libraries (.NET Framework) • Base class libraries, ADO.NET and XML • Windows Forms for rich, Win32 applications • Web application platform ASP.NET • Easier to deploy, run, & maintain applications • For components, versioning, availability

  3. Key Terms (as used in this talk) • Globalization (a.k.a. Internationalization) • Core application handles international data • Character encodings • Date and time, numeric, currency formats • … • Market adaptation • Additional functionality for a given market • Localization = translation • Localizable = ready for translation • Resources • Application elements (error messages, UI) to be translated in localized versions

  4. Why include international support in the Framework ? • Consistency • .NET Framework is Unicode internally • .NET Framework carries NLS+ classes, sorting tables • Consistent results on Windows XP, Windows 2000, Windows NT 4, Windows Millennium, Windows 98 • Note: there are a few limitations on down-level Unicode support: • Underlying operating system limitations • Windows Code pages • File I/O

  5. .NET Framework Namespace System.Web System.WinForms Services UI Design ComponentModel Description HtmlControls Discovery WebControls Protocols System.Drawing Caching Security Drawing2D Printing Text Configuration SessionState Imaging System.Data System.Xml ADO SQL XSLT Serialization Design SQLTypes XPath System Collections IO Security Runtime InteropServices Configuration Net ServiceProcess Remoting Diagnostics Reflection Text Serialization Globalization Resources Threading

  6. System.Globalization Namespace • Includes classes for functionality such as: • Culture-aware string comparison • AABC vs. ABCC (ordinal: codepoint values) • Coté vs. Côte (culture dependent) • Date & Time formatting • yy/mm/dd vs. dd/mm/yy • Numeric formatting • 12,000.00 vs. 12.000,00 • Calendars • Gregorian and non-Gregorian • Starting point : the CultureInfo class

  7. CultureInfo • Provider of cultural preferences • Two roles • CurrentCulture • Date and number formatting • String comparison and casing • … • CurrentUICulture • Resource selection for user interface • Can be controlled on a per thread basis • RFC 1766 derived hierarchy • CultureInfo.CreateSpecificCulture • Optional mapping from neutral to specific

  8. CultureInfo • Cultural preferences provider • Invariant culture • culture-invariant default • Neutral culture • Based on language • Resource only • No formatting • CurrentUICulture only • Specific culture • Based on language & region • Resource & Formatting specifics • CurrentCulture & CurrentUICulture

  9. CultureInfo and related classes Demo

  10. How to Set Culture and UICulture Implicitly • CurrentUICulture • Picked up from GetUserDefaultUILanguage • On Windows XP and Windows 2000 MUI SKUs, this setting can be set by end-user • Otherwise, set from OS resources language • CurrentCulture • Picked up from GetUserDefaultLCID • Affected by changes to Control Panel | Regional Options | Set Locale

  11. How to Set CurrentCulture, CurrentUICulture Explicitly • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“ja”) • Thread.CurrentThread.CurrentCulture = new CultureInfo(“ja-JP”) • Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0)) • Within an individual API that takes a culture • Str = DateTime.Now.ToString(cultureInfo);

  12. What if I don’t want formatting to change by culture? • For UI, prefer culture-sensitive formatting • However, for wire-transfer, database storage, you may want stable, culture-unrelated format, such as • #,###.## • dd MMMM yyyy HH:mm:ss GMT • international currency symbol • Use CultureInfo.InvariantCulture

  13. Culture-aware Classes • Any API which takes a culture, or an IFormatProvider • Culture-sensitive by default • Examples • System.Globalization.CompareInfo • System.Globalization.StringInfo • System.Globalization.Calendar • System.Resources • System.DateTime • System.String

  14. Culture-aware Classes • Calendar classes • Includes support for • Gregorian Calendar • Hebrew Calendar • Hijiri Calendar • Japanese Calendar • Julian Calendar • Korean Calendar • Taiwan Calendar • Thai Buddhist Calendar • Base Calendar class from which custom calendars can be derived

  15. Culture-aware Classes • DateTime • Provides methods that enable culture-sensitive operations on a DateTime. • Use the DateTimeFormatInfo Class to format and display a DateTime based on culture. • DateTimeFormatInfo • Defines how DateTime values are formatted and displayed, depending on the culture.

  16. Culture-aware Classes • NumberFormatInfo • Defines how currency, decimal separator and other numeric symbols are formatted and displayed based on culture

  17. Culture-aware Classes • CompareInfo • Provides a set of methods that can be used to perfomr culture-sensitive string comparisons • The CultureInfo class has a CompareInfo property that is an instance of the CompareInfo class • The String.Compare method uses the information in the CultureInfo.CompareInfo property to compare strings

  18. Unicode support • Unicode everywhere • Unicode internally • UTF-8 and UTF-16 encoding classes • String operations • Surrogates & Combining characters support • Character type information • Based on Unicode 3.0 tables • Unicode category enumeration • CultureInfo data • Caveats • OS dependent operations • Controls support • File System

  19. ASP.NET And International • ASP.NET delivers improved support for international application development: • Can leverage .NET Framework base classes • System.Globalization • System.Text (encodings) • System.Resources • Can separate resources from source code • Unicode-enabled • More options for specifying encoding

  20. ASP.NET setting culture and encoding: • Programmatically Thread.CurrentThread.CurrentCulture =………. • In a Page directive <%@Page ResponseEncoding=“utf-8” %> • In a Configuration file (web.config) Per application or per machine <globalization culture=“de-DE” fileEncoding=“utf-8” /> The most specific setting has precedence : • Programmatic overrides Page Directive, • Page Directive overrides Configuration file

  21. ASP.NET Demo

  22. Additional References • Documentation • .NET Framework SDK: • Developing World-Ready Applications • Tutorials • Samples • Visual Studio : • Visual Studio.NET\Visual Basic and VisualC#\Globalizing and Localizing\Walkthroughs • General info on .NET Framework: • http://msdn.microsoft.com/net • http://www.GotDotNet.com • General info on globalization: • http://www.microsoft.com/globaldev

  23. Questions ?

More Related