Microsoft .NET Development Platform Internationalization

6,215 views

Published on

Globalization namespace
Culture-sensitive classes
Resource model

Published in: Technology
3 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total views
6,215
On SlideShare
0
From Embeds
0
Number of Embeds
71
Actions
Shares
0
Downloads
0
Comments
3
Likes
4
Embeds 0
No embeds

No notes for slide
  • Microsoft .NET Development Platform Internationalization

    1. 1. Microsoft .NET Development Platform Internationalization Rishi Kothari Jyothi Prasad
    2. 2. .NET Internationalization Overview <ul><li>The .NET Framework provides a rich set of object class libraries, integrated into its Common Language Runtime. This framework enables developers to program against a single object model that works across multiple programming languages, operating systems, and cultures/locales. </li></ul><ul><li>Visual Studio .NET builds on this foundation, providing a unified development environment for both Windows and .NET Framework. Its solid Unicode and international support allows for the rapid development of globally-aware Windows and Web applications. </li></ul>
    3. 3. .NET Internationalization Agenda <ul><li>.NET Framework </li></ul><ul><ul><li>Globalization namespace </li></ul></ul><ul><ul><li>Culture-sensitive classes </li></ul></ul><ul><ul><li>Resource model </li></ul></ul><ul><li>ASP .NET </li></ul><ul><ul><li>International support </li></ul></ul><ul><ul><li>Localization options </li></ul></ul><ul><li>Visual Studio .NET </li></ul><ul><ul><li>Unicode support </li></ul></ul><ul><ul><li>Windows and Web Form international support </li></ul></ul><ul><ul><li>Windows and Web Form localization </li></ul></ul><ul><li>References </li></ul>
    4. 4. .NET Framework Background <ul><li>Microsoft's platform for building, deploying, operating and integrating XML Web services </li></ul><ul><li>Rich XML, standard protocols, stateless </li></ul><ul><li>Cross-language development </li></ul><ul><ul><li>Common language runtime </li></ul></ul><ul><ul><ul><li>Common type system for all languages </li></ul></ul></ul><ul><ul><ul><li>Rich runtime environment </li></ul></ul></ul><ul><ul><li>Rich class libraries (.NET Framework) </li></ul></ul><ul><ul><ul><li>Base class libraries, ADO.NET and XML </li></ul></ul></ul><ul><ul><ul><li>Windows Forms for rich, Win32 applications </li></ul></ul></ul><ul><ul><ul><li>Web application platform ASP.NET </li></ul></ul></ul><ul><li>Easier to deploy, run, & maintain applications </li></ul><ul><ul><li>For components, versioning, availability </li></ul></ul>
    5. 5. . NET Framework Globalization <ul><li>Unicode internally </li></ul><ul><ul><li>UTF-8 and UTF-16 encoding classes </li></ul></ul><ul><ul><li>Surrogates & Combining characters support </li></ul></ul><ul><ul><li>Character type information </li></ul></ul><ul><li>Carries NLS+ classes, sorting tables </li></ul><ul><li>Consistent results on Windows XP, Windows 2000, Windows NT 4, Windows Millennium, Windows 98 </li></ul><ul><li>Limitations on down-level Unicode support: </li></ul><ul><ul><li>Underlying operating system limitations </li></ul></ul><ul><ul><li>File I/O (Windows code pages) </li></ul></ul><ul><ul><li>Some Win9x controls are ANSI-only </li></ul></ul>
    6. 6. .NET Framework Namespace s System System.Data System.Xml System.Web Globalization Diagnostics Configuration Collections Resources Reflection Net IO Threading Text ServiceProcess Security Design ADO SQLTypes SQL XPath XSLT Runtime InteropServices Remoting Serialization Serialization Configuration SessionState Caching Security Services Description Discovery Protocols UI HtmlControls WebControls System.Drawing Imaging Drawing2D Text Printing System.WinForms Design ComponentModel
    7. 7. .NET Framework System.Globalization <ul><li>Includes classes for functionality such as: </li></ul><ul><ul><li>Culture-aware string comparison </li></ul></ul><ul><ul><ul><li>AABC vs. ABCC (ordinal: codepoint values) </li></ul></ul></ul><ul><ul><ul><li>Coté vs. Côte (culture dependent) </li></ul></ul></ul><ul><ul><li>Date & Time formatting </li></ul></ul><ul><ul><ul><li>yy/mm/dd vs. dd/mm/yy </li></ul></ul></ul><ul><ul><li>Numeric formatting </li></ul></ul><ul><ul><ul><li>12,000.00 vs. 12.000,00 </li></ul></ul></ul><ul><ul><li>Calendars </li></ul></ul><ul><ul><ul><li>Gregorian and non-Gregorian </li></ul></ul></ul><ul><li>Starting point : CultureInfo class </li></ul>
    8. 8. .NET Framework System.Globalization. CultureInfo <ul><li>Cultural preferences provider </li></ul><ul><li>Two roles </li></ul><ul><ul><li>CurrentCulture </li></ul></ul><ul><ul><ul><li>Date and number formatting </li></ul></ul></ul><ul><ul><ul><li>String comparison and casing </li></ul></ul></ul><ul><ul><ul><li>… </li></ul></ul></ul><ul><ul><li>CurrentUICulture </li></ul></ul><ul><ul><ul><li>Resource selection for user interface </li></ul></ul></ul><ul><ul><li>Can be controlled on a per thread basis </li></ul></ul><ul><li>CultureInfo.CreateSpecificCulture </li></ul><ul><ul><li>Optional mapping from neutral to specific </li></ul></ul>
    9. 9. .NET Framework System.Globalization. CultureInfo (continued) <ul><li>RFC 1766 derived hierarchy </li></ul><ul><li>Invariant culture </li></ul><ul><ul><li>Culture-invariant default </li></ul></ul><ul><li>Neutral culture </li></ul><ul><ul><li>Based on language </li></ul></ul><ul><ul><li>Resource only </li></ul></ul><ul><ul><li>CurrentUICulture only </li></ul></ul><ul><li>Specific culture </li></ul><ul><ul><li>Based on language & region </li></ul></ul><ul><ul><li>Resource & Formatting specifics </li></ul></ul><ul><ul><li>CurrentCulture & CurrentUICulture </li></ul></ul>invariant de de-AT de-CH de-DE de-LI de-LU en
    10. 10. .NET Framework CultureInfo.InvariantCulture <ul><li>For UI, culture-sensitive formatting preferred </li></ul><ul><li>F or wire-transfer or data storage, a stable, culture- neutral format may be preferred: </li></ul><ul><ul><li>#,###.## </li></ul></ul><ul><ul><li>dd MMMM yyyy HH:mm:ss GMT </li></ul></ul><ul><ul><li>international currency symbol </li></ul></ul><ul><li>Use CultureInfo.InvariantCulture </li></ul>
    11. 11. .NET Framework Setting Cultures Explicitly <ul><li>CurrentUICulture </li></ul><ul><ul><li>Thread.CurrentThread.CurrentUICulture = new CultureInfo(“ja”) </li></ul></ul><ul><li>CurrentCulture </li></ul><ul><ul><li>Thread.CurrentThread.CurrentCulture = new CultureInfo(“ja-JP”) </li></ul></ul><ul><li>CreateSpecificCulture </li></ul><ul><ul><li>Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0)) </li></ul></ul><ul><li>Within an individual API that takes a culture </li></ul><ul><ul><li>Str = DateTime.Now.ToString( C ultureInfo); </li></ul></ul>
    12. 12. .NET Framework Culture-aware classes <ul><li>Any API that takes a culture or IFormatProvider </li></ul><ul><li>Culture-sensitive by default </li></ul><ul><li>Examples (see Appendix for more info) : </li></ul><ul><ul><li>System.Globalization.CompareInfo </li></ul></ul><ul><ul><li>System.Globalization.StringInfo </li></ul></ul><ul><ul><li>System.Globalization.Calendar </li></ul></ul><ul><ul><li>System.Resources </li></ul></ul><ul><ul><li>System.DateTime </li></ul></ul><ul><ul><li>System.String </li></ul></ul>
    13. 13. .NET Framework System.Globalization.CultureInfo Demo
    14. 14. .NET Framework System.Resources namespace <ul><li>ResourceManager </li></ul><ul><ul><li>Provides access to culture-correct resources at runtime </li></ul></ul><ul><li>ResourceWriter </li></ul><ul><ul><li>Writes resources to an output stream or file </li></ul></ul><ul><li>ResourceReader </li></ul><ul><ul><li>Reads resources name-value pairs from resources files and streams </li></ul></ul><ul><li>ResourceSet </li></ul><ul><ul><li>Stores all resources localized for a particular culture </li></ul></ul>
    15. 15. .NET Framework Resource generation process <ul><li>.resx file </li></ul><ul><ul><li>XML-based </li></ul></ul><ul><ul><li>Describes resources </li></ul></ul><ul><li>.resources file </li></ul><ul><ul><li>Binary compiled file </li></ul></ul><ul><li>Satellite .resources.dll </li></ul><ul><ul><li>Embedded .resources file(s) </li></ul></ul>.resx file .resources file .resources.dll file
    16. 16. .NET Framework Naming conventions <ul><li>Naming pattern conventions </li></ul><ul><ul><li>.resources files: </li></ul></ul><ul><ul><ul><li><myproject>.<xx-XX>.resources </li></ul></ul></ul><ul><ul><li>Satellite assemblies </li></ul></ul><ul><ul><ul><li><myproject>.resources.dll </li></ul></ul></ul><ul><li>Directory locations for satellites: </li></ul><ul><ul><li>A subdirectory per culture </li></ul></ul><ul><ul><li>either neutral or specific cultures can be used </li></ul></ul><ul><ul><li>Myproject.dll </li></ul></ul><ul><ul><ul><li>demyproject.resources.dll (neutral) </li></ul></ul></ul><ul><ul><ul><li>de-DEmyproject.resources.dll (specific) </li></ul></ul></ul>
    17. 17. .NET Framework Loading resources <ul><li>Loads requested resources based on Thread.CurrentThread.CurrentUICulture </li></ul><ul><li>Creating a Resource Manager </li></ul><ul><ul><li>RM constructor indicates which file to load resource from </li></ul></ul><ul><ul><li>Alternatives: </li></ul></ul><ul><ul><ul><li>Load from a loose .resources file </li></ul></ul></ul><ul><ul><ul><li>Load from this assembly </li></ul></ul></ul><ul><ul><ul><li>Load from another assembly </li></ul></ul></ul><ul><ul><ul><li>Load from a custom resource format, using own resource manager (e.g. a database) </li></ul></ul></ul><ul><ul><li>See .NET SDK, Samples and Tutorials, ASP.NET QuickStarts, and How Do I … samples </li></ul></ul>
    18. 18. .NET Framework Resource fallback <ul><li>Main Assembly </li></ul><ul><li>Code </li></ul><ul><li>Default resources (fallback) </li></ul><ul><ul><li>Greeting=“Hello” </li></ul></ul><ul><ul><li>Farewell=“Goodbye” </li></ul></ul><ul><ul><li>Logo=<graphic data> </li></ul></ul><ul><li>French </li></ul><ul><li>No code </li></ul><ul><li>“ fr” resources </li></ul><ul><ul><li>Greeting = “Bonjour” </li></ul></ul><ul><ul><li>Farewell = “Au revoir” </li></ul></ul><ul><li>French (France) (fr-FR) </li></ul><ul><li>No code </li></ul><ul><li>“ fr-FR” resources </li></ul><ul><ul><li>Greeting=“Salut” </li></ul></ul>
    19. 19. .NET Internationalization Agenda <ul><li>.NET Framework </li></ul><ul><ul><li>Globalization namespace </li></ul></ul><ul><ul><li>Culture-sensitive classes </li></ul></ul><ul><ul><li>Resource model </li></ul></ul><ul><li>ASP .NET </li></ul><ul><ul><li>International support </li></ul></ul><ul><ul><li>Localization options </li></ul></ul><ul><li>Visual Studio .NET </li></ul><ul><ul><li>Unicode support </li></ul></ul><ul><ul><li>Windows and Web Form international support </li></ul></ul><ul><ul><li>Windows and Web Form localization </li></ul></ul><ul><li>References </li></ul>
    20. 20. ASP.NET International support <ul><li>Delivers improved support for international application development: </li></ul><ul><ul><li>Can leverage .NET Framework base classes </li></ul></ul><ul><ul><ul><li>System.Globalization </li></ul></ul></ul><ul><ul><ul><li>System.Text (encodings) </li></ul></ul></ul><ul><ul><ul><li>System.Resources </li></ul></ul></ul><ul><ul><li>Can separate resources from source code </li></ul></ul><ul><ul><li>Unicode-enabled </li></ul></ul><ul><ul><li>More options for specifying encoding </li></ul></ul>
    21. 21. ASP .NET C ulture and e ncoding <ul><li>Programmatically </li></ul><ul><ul><li>Thread.CurrentThread.CurrentCulture =………. </li></ul></ul><ul><li>Page directive </li></ul><ul><ul><li><%@Page ResponseEncoding=“utf-8” %> </li></ul></ul><ul><li>Configuration file (web.config) </li></ul><ul><ul><li>Per application or per machine </li></ul></ul><ul><ul><li><globalization </li></ul></ul><ul><ul><li>culture=“de-DE” </li></ul></ul><ul><ul><li>fileEncoding=“utf-8” /> </li></ul></ul><ul><li>Most specific setting has precedence: </li></ul><ul><li>Programmatic overrides p age d irective </li></ul><ul><li>Page d irective overrides c onfiguration file </li></ul>
    22. 22. ASP .NET Localization recommendations <ul><li>Resources separated from source </li></ul><ul><li>Use Resource Manager to load resources </li></ul><ul><li>Resources could be in </li></ul><ul><ul><li>Loose .resources files </li></ul></ul><ul><ul><li>Satellites below each main assembly </li></ul></ul><ul><ul><li>A separate (parallel) main assembly with satellites below it </li></ul></ul><ul><li>One .resources file or satellite per language </li></ul><ul><li>Slightly different ResourceManager constructors for each case </li></ul>
    23. 23. ASP.NET Localization recommendations (continued) <ul><li>Advantages: </li></ul><ul><ul><li>Can deploy additional languages incrementally, without redeploying core code </li></ul></ul><ul><ul><li>Lower maintenance costs, as there is one central app, not many parallel versions </li></ul></ul><ul><li>Disadvantages: </li></ul><ul><ul><li>More files </li></ul></ul><ul><ul><li>Loose .resources can have locking issue. </li></ul></ul><ul><ul><ul><li>No locking issue for satellites or parallel main assembly with satellites </li></ul></ul></ul><ul><ul><ul><li>Shadow-copying done for exes and dlls (main assemblies and satellites) </li></ul></ul></ul><ul><li>Samples: ASP.NET Quickstarts, Localization section </li></ul>
    24. 24. .NET Internationalization Agenda <ul><li>Microsoft .NET Framework </li></ul><ul><ul><li>Globalization namespace </li></ul></ul><ul><ul><li>Culture-sensitive classes </li></ul></ul><ul><ul><li>Resource model </li></ul></ul><ul><li>ASP .NET </li></ul><ul><ul><li>International support </li></ul></ul><ul><ul><li>Localization options </li></ul></ul><ul><li>Microsoft Visual Studio .NET </li></ul><ul><ul><li>Unicode support </li></ul></ul><ul><ul><li>Windows and Web Form international support </li></ul></ul><ul><ul><li>Windows and Web Form localization </li></ul></ul><ul><li>References </li></ul>
    25. 25. Visual Studio .NET Unicode support - Development Environment <ul><li>Development environment is Unicode-enabled, with some exceptions: </li></ul><ul><ul><li>resource editor for Win32 resources </li></ul></ul><ul><ul><li>some debugger dialogs </li></ul></ul><ul><ul><li>some wizards </li></ul></ul><ul><li>Source code editor </li></ul><ul><ul><li>allows the editing of all scripts including complex scripts </li></ul></ul><ul><ul><li>uses font linking to render characters outside the current font </li></ul></ul>
    26. 26. Visual Studio .NET Unicode support - Compilers <ul><li>Visual Basic .NET, Visual C ♯ .NET and Visual JScript .NET </li></ul><ul><ul><li>All use Unicode-encoded source code (UTF-16) as input </li></ul></ul><ul><ul><li>Automatic conversion from a range of different character encodings: </li></ul></ul><ul><ul><ul><li>Byte-order-mark at the start of the file for detecting UTF-forms </li></ul></ul></ul><ul><ul><ul><li>/codepage compiler option for Visual C ♯ .NET and Visual JScript .NET </li></ul></ul></ul><ul><li>Managed Extensions for C++ </li></ul><ul><ul><li>Exception: uses Windows codepages (configurable) and ASCII identifiers </li></ul></ul>
    27. 27. Visual Studio .NET International support for Windows Forms <ul><li>Windows Forms are Unicode forms on all Windows platforms (some small limitations with legacy controls on Windows 98 and Windows ME) </li></ul><ul><li>Windows Forms have a font linking mechanism </li></ul><ul><li>Windows Forms support bi-directional layout and complex scripts rendering </li></ul><ul><li>Culture-aware controls such as DateTime picker and Calendar </li></ul>
    28. 28. Visual Studio .NET Windows Forms localization – VS .NET Editor <ul><li>Windows Forms provide localization support: </li></ul><ul><ul><li>Every form has a Localizable property </li></ul></ul><ul><ul><li>Localizable property set to True : </li></ul></ul><ul><ul><ul><li>Project system automatically keeps track of different language versions of a form </li></ul></ul></ul><ul><ul><ul><li>Builds the different language forms into satellite assemblies </li></ul></ul></ul><ul><li>The resource format used is an XML format (RESX) that gets compiled into a binary format </li></ul><ul><li>Any XML localization tool can be used </li></ul><ul><li>.NET Development Platform SDK contains a standalone visual editing tool: WinRes </li></ul><ul><li>3 rd parties are enabling their localization tools to deal with the new resource formats (Alchemy, Lionbridge) </li></ul>
    29. 29. Visual Studio .NET Web Forms localization – VS .NET Editor <ul><li>Web Forms designer fully supports flow-layout of ASP .NET pages </li></ul><ul><li>.RESX resource format </li></ul><ul><ul><li>can be used for string resources </li></ul></ul><ul><ul><li>is supported by the project system in the development environment </li></ul></ul>
    30. 30. .NET Internationalization Agenda <ul><li>.NET Framework </li></ul><ul><ul><li>Globalization namespace </li></ul></ul><ul><ul><li>Culture-sensitive classes </li></ul></ul><ul><ul><li>Resource model </li></ul></ul><ul><li>ASP .NET </li></ul><ul><ul><li>International support </li></ul></ul><ul><ul><li>Localization options </li></ul></ul><ul><li>Visual Studio .NET </li></ul><ul><ul><li>Unicode support </li></ul></ul><ul><ul><li>Windows and Web Form international support </li></ul></ul><ul><ul><li>Web Services and Deployment international support </li></ul></ul><ul><ul><li>Windows and Web Form localization </li></ul></ul><ul><li>References </li></ul>
    31. 31. References .NET Framework <ul><li>Documentation </li></ul><ul><ul><li>.NET Framework SDK: </li></ul></ul><ul><ul><ul><li>Developing World-Ready Applications </li></ul></ul></ul><ul><ul><ul><li>Tutorials </li></ul></ul></ul><ul><ul><ul><li>Samples </li></ul></ul></ul><ul><ul><li>Visual Studio : </li></ul></ul><ul><ul><ul><li>Visual Studio.NETVisual Basic and VisualC#Globalizing and LocalizingWalkthroughs </li></ul></ul></ul><ul><li>General info on .NET Framework: </li></ul><ul><ul><li>http://msdn.microsoft.com/net </li></ul></ul><ul><ul><li>http:// www.GotDotNet.com </li></ul></ul><ul><li>General info on globalization: </li></ul><ul><ul><li>http://www.microsoft.com/ globaldev </li></ul></ul>
    32. 32. References Visual Studio .NET <ul><li>http://msdn.microsoft.com/vstudio/ </li></ul><ul><li>Visual Studio documentation: </li></ul><ul><ul><li>Visual Studio .NETVisual Basic and Visual C#Globalizing and Localizing </li></ul></ul><ul><li>Microsoft Layer for Unicode: contained in the July 2001 Platform SDK http://www.microsoft.com/msdownload/platformsdk/setuplauncher.asp </li></ul>
    33. 33. References XML & UDDI <ul><li>W3C XML Protocol Activity </li></ul><ul><ul><li>http://www.w3.org/2000/xp/ </li></ul></ul><ul><li>UDDI (Universal Description, Discovery and Integration) </li></ul><ul><ul><li>http:// www.uddi.org / </li></ul></ul>
    34. 34. Appendix .NET Framework Calendar classes <ul><li>Gregorian Calendar </li></ul><ul><li>Hebrew Calendar </li></ul><ul><li>Hijiri Calendar </li></ul><ul><li>Japanese Calendar </li></ul><ul><li>Julian Calendar </li></ul><ul><li>Korean Calendar </li></ul><ul><li>Taiwan Calendar </li></ul><ul><li>Thai Buddhist Calendar </li></ul><ul><li>Base Calendar class (derive custom calendars ) </li></ul>
    35. 35. Appendix .NET Framework: DateTime & DateTimeFormatInfo c lasses <ul><li>DateTime </li></ul><ul><ul><li>Provides methods that enable culture-sensitive operations on a DateTime. </li></ul></ul><ul><ul><li>Use the DateTimeFormatInfo Class to format and display a DateTime based on culture. </li></ul></ul><ul><li>DateTimeFormatInfo </li></ul><ul><ul><li>Defines how DateTime values are formatted and displayed, depending on the culture. </li></ul></ul>
    36. 36. Appendix .NET Framework: NumberFormatInfo class <ul><li>NumberFormatInfo </li></ul><ul><ul><li>Defines how currency, decimal separator and other numeric symbols are formatted and displayed , based on culture </li></ul></ul>
    37. 37. Appendix .NET Framework: CompareInfo class <ul><li>CompareInfo </li></ul><ul><ul><li>Provides a set of methods that can be used to perfomr culture-sensitive string comparisons </li></ul></ul><ul><ul><li>The CultureInfo class has a CompareInfo property that is an instance of the CompareInfo class </li></ul></ul><ul><ul><li>The String.Compare method uses the information in the CultureInfo.CompareInfo property to compare strings </li></ul></ul>
    38. 38. Appendix VS .NET: New intl support for native C++ applications <ul><li>MFC and ATL libraries support the new Microsoft Layer for Unicode (MSLU) for Windows 98 and Windows ME </li></ul><ul><li>MFC application wizard provides templates for 9 different languages </li></ul><ul><li>ATL Server supports the creation of Unicode ISAPI Web applications and provides locale support in conjunction with the C runtime </li></ul>
    39. 39. Appendix VS .NET: International support for XML Web Services <ul><li>Based on standard efforts - SOAP and UDDI </li></ul><ul><li>SOAP (Simple Object Access Protocol) </li></ul><ul><ul><li>based on XML and HTTP </li></ul></ul><ul><ul><li>globalized data types </li></ul></ul><ul><li>UDDI (Universal Description, Discovery and Integration) </li></ul><ul><ul><li>based on SOAP </li></ul></ul><ul><ul><li>version 2.0 introduced improvements for i18n </li></ul></ul><ul><li>Visual Studio .NET contains support to easily produce, consume, and debug XML Web Services </li></ul>
    40. 40. Appendix VS .NET: International support for Deployment <ul><li>Visual Studio Deployment projects allow you to create deployment projects in nine languages, including: </li></ul><ul><ul><li>English </li></ul></ul><ul><ul><li>German </li></ul></ul><ul><ul><li>French </li></ul></ul><ul><ul><li>Italian </li></ul></ul><ul><ul><li>Spanish </li></ul></ul><ul><ul><li>Japanese </li></ul></ul><ul><ul><li>Korean </li></ul></ul><ul><ul><li>Chinese (simplified and traditional) </li></ul></ul>

    ×