Developing International Applications with Visual Studio 2005 11/23/2018 7:01 AM Developing International Applications with Visual Studio 2005 Marin Millar Globalization Manager Microsoft © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Overview Goals Introduce new globalization and localization features in .NET Framework 2.0 and Visual Studio 2005 Topics .NET Runtime Windows Forms ASP .NET 26th Internationalization and Unicode Conference 2
.NET Framework 2.0 Custom Cultures Supplementary Character Support IDN Normalization New Calendars Resources 26th Internationalization and Unicode Conference 3
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Custom Cultures Custom culture examples Replacement Cultures Replacing or adding customizations to existing cultures Ex: ja-JP-MyCompany or en-US-24hr Supplemental Cultures New combination of language and location es-US for Spanish in the US Tagalog in Guam 26th Internationalization and Unicode Conference 4 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Custom Culture in 1.0/1.1 Set CurrentCulture and CurrentUIculture to different values Example: es-US (Spanish-United States) set CurrentThread.CurrentUICulture to es (for resources) set CurrentThread.CurrentCulture to en-US (for formatting) Disadvantages Date text is English, unless DTFI is overridden Override CultureInfo to create custom culture Existing custom culture sample on GotDotNet http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=a193b952-2e44-45ed-811d-c1fabf2f6e8a Devs have to create their own implementations. Solution is not supported in the CultureInfo mechanism i.e., not included in cultures list for CultureInfo.GetAllCultures App domain limitation: custom culture must be recreated across app domains 26th Internationalization and Unicode Conference 5
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Custom Cultures in 2.0 Goal: Easily define new cultures Easily deploy new cultures Custom cultures are equivalent to pre-defined cultures Return all cultures, including custom cultures CultureInfo.GetCultures(CultureTypes.AllAvailableCultures) Return custom cultures only CultureInfo.GetCultures(CultureTypes.UserCustomCultures) Standardized solution No need to make separate DTFI updates change date display language No limitations across app domains 26th Internationalization and Unicode Conference 6 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Custom cultures Limitations String name “en-US-MyCompany” is unique; LCID is not One LCID per custom culture LCID assigned to user-default locale Changing the user-default locale to custom culture: String name changes LCID does not change No UI designer for custom cultures Cannot use custom classes for CultureInfo classes such as CompareInfo, TextInfo, Calendar Can customize cultures to use existing classes 26th Internationalization and Unicode Conference 7 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Personalize A Culture CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder(new CultureInfo("en-US", false), null, “en”, “US”, “MyCompany"); carib.DateTimeFormat.LongTimePattern = “HH:mm:ss”; carib.Register(); CultureInfo ci = new CultureInfo("en-US-MyCompany”); //-OR- Save and register a file: carib.Save("c:\\temp\\myculture.xml"); CultureAndRegionInfoBuilder.Register(“c:\\tmp\\myculture.xml”); 26th Internationalization and Unicode Conference 8 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Create A New Culture CultureInfo ciES = new CultureInfo("es-ES"); CultureInfo ciUS = new CultureInfo("en-US"); CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder(ciEs, null, "es", "US"); carib.NumberFormat.CurrencySymbol = ciUS.NumberFormat.CurrencySymbol; carib.DateTimeFormat = ciUS.DateTimeFormat; carib.DateTimeFormat.DayNames = ciES.DateTimeFormat.DayNames; carib.DateTimeFormat.MonthNames = ciES.DateTimeFormat.MonthNames; carib.DateTimeFormat.AbbreviatedDayNames = ciES.DateTimeFormat.AbbreviatedDayNames; carib.DateTimeFormat.AbbreviatedMonthNames = ciES.DateTimeFormat.AbbreviatedMonthNames ; carib.Register(); CultureInfo ci = new CultureInfo("es-US"); 26th Internationalization and Unicode Conference 9 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Developing a Custom Culture Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 10 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
International Domain Names Developing International Applications with Visual Studio 11/23/2018 7:01 AM International Domain Names New Standard (IDN) http://www.ietf.org/html.charters/idn-charter.html Enables non-ASCII domain names www.loréal.com www.日本語.com IDN Mapping class containing IDN conversion APIs System.Globalization.IdnMapping GetAscii and GetUnicode provide host name conversion between native Unicode and Punycode Limitations This support does not cover IRIs Standard is not yet finalized Not yet implemented in System.Net URI/IRI classes 26th Internationalization and Unicode Conference 11 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM International Domain Names Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 12 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Normalization Support 4 normalization forms (C,D,KC,KD) Composition, shortest form Decomposition, longest form Normalize strings public string Normalize(System.Text.NormalizationForm normalizationForm) Verify normalization or normalization form public bool IsNormalized(System.Text.NormalizationForm normalizationForm) Implementation conforms to sample in Unicode Tech Report 15: http://www.unicode.org/reports/tr15/. 26th Internationalization and Unicode Conference 13 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Supplementary Characters Developing International Applications with Visual Studio 11/23/2018 7:01 AM Supplementary Characters v. 1.0, 1.1 Methods on StringInfo to parse characters and walk text elements v. 2.0 Additional methods on StringInfo to find surrogate pairs in substrings public string SubstringByTextElements(int startingTextElement, int lengthInTextElements) New property to determine length of strings containing surrogate pairs public int LengthInTextElements [get] Char.IsLetter recognizes surrogate pairs New methods in System.Char class to detect high and low surrogate codepoints New methods to convert between Unicode and UTF-32 Use Unicode or UTF-8 for better performance 26th Internationalization and Unicode Conference 14 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Supplementary Characters Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 15 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM New Calendars Enable date conversions between regional calendars New algorithms include: UmAlQura calendar Implementation of Hijiri calendar Jalaali calendar Calander used in Farsi communities East Asian Lunisolar calendars PRC Taiwan Japan Korea 26th Internationalization and Unicode Conference 16 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Resource Model Additions Developing International Applications with Visual Studio 11/23/2018 7:01 AM Resource Model Additions Strongly Typed Resources What are they? Creates classes containing read-only properties for resources Benefits: Provides Intellisense on resource identifiers No need to create a ResourceManager Eliminates mismatches between code and resource identifiers No need to cast objects to other types Additional fallback resource location v. 1.0/1.1 – ResourceManager only loaded fallback resources from the main assembly v. 2.0 – Adds ability to build fallback resources in a satellite assembly public NeutralResourcesLanguageAttribute(string cultureName, System.Resources.UltimateResourceFallbackLocation location) 26th Internationalization and Unicode Conference 17 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Resource Performance Suggestions Developing International Applications with Visual Studio 11/23/2018 7:01 AM Resource Performance Suggestions Put satellite assemblies in the GAC Satellite assemblies in the GAC are FAR more performant Use ResourceManager.GetStream for image resources Returns an unmanaged memory stream for images Far more performant than GetObject public System.IO.UnmanagedMemoryStream GetStream(string name) Use Culture-Neutral Images Loading images is expensive Using culture-neutral images can save a lot on performance Use NeutralLanguageResources Attribute Specifies the language of the default resources Eliminates probing for the neutral language resources 26th Internationalization and Unicode Conference 18 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Strongly Typed Resources Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 19 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Windows Forms Localization 1.0 Each form has a localizable property Create single .resx file per form Edit source/localized .resx files in the Windows Forms designer or XML editor Images serialized into .resx file Pulled each localizable property from the .resx file Built satellite assemblies directly in VS Setup projects available in 9 languages 26th Internationalization and Unicode Conference 20
Windows Forms Localization 2.0 Localizable property remains the same One .resx file per form Images Linked into resx files rather than serialized Default to app wide .resx file Edit source/localized resources in resource designer New layout functionality reduces resizing during localization Deploy Click Once projects in any language 26th Internationalization and Unicode Conference 21
Localize Without Resizing Developing International Applications with Visual Studio 11/23/2018 7:01 AM Localize Without Resizing 1.0/1.1 Use docking and anchoring properties 2.0 Two new controls Use TableLayoutPanel for: Resizing a group of controls proportionally Dynamically generating UI with customizable fields Creating a fixed size UI while still allowing localization Use FlowLayoutPanel for: Creating a series of horizontal controls which may wrap vertically but aren’t proportional to each other Mechanism for “bumping” controls relative to other controls 26th Internationalization and Unicode Conference 22 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Using Layout Controls Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 23 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
RightToLeft Languages Developing International Applications with Visual Studio 11/23/2018 7:01 AM RightToLeft Languages v. 1.0/1.1 Controls supported RightToLeft reading order Partial RightToLeft alignment and layout v. 2.0 New RightToLeft behavior for: Form, Treeview, StatusBar, ListView, Panel, ProgressBar, Tab, Splitter Controls support full “mirroring” RightToLeft reading order RightToLeft alignment RightToLeft layout 26th Internationalization and Unicode Conference 24 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Click Once New deployment mechanism Deploy multiple languages from a single project Language property determines: language satellite assemblies language external dependencies Click once language resources (.xml files) Can extend ClickOnce resource languages by localizing setup.xml 26th Internationalization and Unicode Conference 25
ASP .NET Localization v. 1.0/1.1 v. 2.0 Used .NET resource model No design time assistance v. 2.0 Uses .NET resource model Provides a simple declarative model for localization Design time resource generation Edit using VS resource editor Server side compile of .resx files Tag to auto-detect browser culture 26th Internationalization and Unicode Conference 26
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Handling Cultures v. 1.0/1.1 Write code to detect browser language Specify preferred culture in web.config, page or code 2.0 Use “auto” to automatically detect browser language <%@ Page culture=“auto:fr” uiculture=“auto:fr-FR” .. %> 26th Internationalization and Unicode Conference 27 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Resources Resource format Global Application Resources Local Resources Use .resx for authoring .NET xml based resource format Global Application Resources Use for global strings or images Stored in \Resources folder Strongly-typed, available to all pages through Resources member. Local Resources Use for page resources Stored in \LocalResources folder Generated through the designer 26th Internationalization and Unicode Conference 28
Handling Local Resources Declaratively Explicit or non-explicit expressions Programmatically System.Web.UI.TemplateControl.GetPageResourceObject() foo.aspx \LocalResources foo.aspx.resx foo.aspx.fr.resx Declaratively: <asp:label runat=“server” id=“foo” text=“<%$ Resources:Title, ‘Welcome’ %>” /> <asp:label runat=“server” meta:ResourceKey=“TitleKey” %> Programmatically: foo.Text = (string)GetPageResourceObject(“Title”, ‘Welcome”); 26th Internationalization and Unicode Conference 29
Bi-directionality Direction property on <asp:panel> Marked Localizable(true) Designer service generates property value in RESX Can be explicitly defined Can be auto assigned through non-explicit expression handling <asp:panel runat=“server” meta:resourcekey=“MainTitle” /> <data name=“MainTitle.Direction” type=“.. ContentDirection”> <value>RightToLeft</value> </data> 26th Internationalization and Unicode Conference 30
Developing International Applications with Visual Studio 11/23/2018 7:01 AM ASP .NET Localization Marin Millar Globalization Manager Developer Division 26th Internationalization and Unicode Conference 31 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Developing International Applications with Visual Studio 11/23/2018 7:01 AM Microsoft Newsgroup: microsoft.public.dotnet.internationalization Localization Partner Program http://www.vsippartners.com/programs/localization More Articles and Code http://www.microsoft.com/globaldev http://www.dotnetdashboard.net/Sessions/globalization.aspx http://msdn.microsoft.com/asp.net/community/authors/mlb/default.aspx?pull=/library/en-us/dnaspp/html/aspnet-globalarchi.asp 26th Internationalization and Unicode Conference 32 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Expressions Declarative syntax Interpreted at runtime Access local or app resources Interpreted at runtime Tool handling in control designers and ‘Expressions …’ (binding) Runtime ‘parse-time’ feature but also support no-compile Explicit and non-explicit forms Explicit form: <%$ Resources:[class,]key[,’default’] %> <asp:label runat=“server” text=“<%$ Resources:MainTitle %>” /> <asp:button runat=“server” text=“<%$ Resources:MyStrings,OK_Key %>”/> Non-explicit form: Meta:ResourceKey=“keyprefix” <asp:label runat=“server” meta:resourcekey=“MainTitle” /> 26th Internationalization and Unicode Conference 33
Explicit Expressions Used on any control or object property Fine-grained handling for properties which are not localizable by default Access application or local resources Runtime Used to obtain resource value and perform property assignment Design-time Developer can create expressions against control properties in “Expressions…” dialog 26th Internationalization and Unicode Conference 34
Non-explicit Expressions Used to partially or fully localize an ‘object’ with minimal syntax Controls, sub-objects, page directive Only used to access local resources Generated by the designer 26th Internationalization and Unicode Conference 35
Non-explicit Expressions Runtime: Default RESX interrogated for keyprefix and properties set Key: filter, keyprefix, control property, sub-property Design-time: Control properties marked [Localizable(true)] are ‘pushed’ to RESX <asp:label runat=“server” meta:resourcekey=“MainTitle” /> <data name=“MainTitle.Text”> <value>Welcome to the site</value> </data> <data name=“MainTitle.Font.Bold” type=“.. Boolean”> <value>true</value> 26th Internationalization and Unicode Conference 36