Developing International Applications with Visual Studio 2005 - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

Developing International Applications with Visual Studio 2005

Description:

Introduce new globalization and localization features in .NET Framework 2.0 and ... www.lor al.com. www.???.com. IDN Mapping class containing IDN conversion APIs ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 37
Provided by: achim
Category:

less

Transcript and Presenter's Notes

Title: Developing International Applications with Visual Studio 2005


1
Developing International Applications with Visual
Studio 2005
  • Marin Millar
  • Globalization Manager
  • Microsoft

2
Overview
  • Goals
  • Introduce new globalization and localization
    features in .NET Framework 2.0 and Visual Studio
    2005
  • Topics
  • .NET Runtime
  • Windows Forms
  • ASP .NET

3
.NET Framework 2.0
  • Custom Cultures
  • Supplementary Character Support
  • IDN
  • Normalization
  • New Calendars
  • Resources

4
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

5
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/Det
    ails.aspx?SampleGuida193b952-2e44-45ed-811d-c1fab
    f2f6e8a
  • Disadvantages
  • 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

6
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.AllAvailableC
    ultures)
  • Return custom cultures only
  • CultureInfo.GetCultures(CultureTypes.UserCustomCul
    tures)
  • Standardized solution
  • No need to make separate DTFI updates change date
    display language
  • No limitations across app domains

7
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

8
Personalize A Culture
  • CultureAndRegionInfoBuilder carib new
    CultureAndRegionInfoBuilder(new
    CultureInfo("en-US", false), null, en, US,
    MyCompany")
  • carib.DateTimeFormat.LongTimePattern
    HHmmss   
  • 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\\myc
    ulture.xml)

9
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")

10
Developing a Custom Culture
Marin Millar Globalization Manager Developer
Division
11
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

12
International Domain Names
Marin Millar Globalization Manager Developer
Division
13
Normalization
  • Support 4 normalization forms (C,D,KC,KD)
  • Composition, shortest form
  • Decomposition, longest form
  • Normalize strings
  • public string Normalize(System.Text.NormalizationF
    orm normalizationForm)
  • Verify normalization or normalization form
  • public bool IsNormalized(System.Text.Normalization
    Form normalizationForm)
  • Implementation conforms to sample in Unicode Tech
    Report 15
  • http//www.unicode.org/reports/tr15/.

14
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

15
Supplementary Characters
Marin Millar Globalization Manager Developer
Division
16
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

17
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.UltimateResourceFall
    backLocation location)

18
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

19
Strongly Typed Resources
Marin Millar Globalization Manager Developer
Division
20
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

21
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

22
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 arent proportional to
    each other
  • Mechanism for bumping controls relative to
    other controls

23
Using Layout Controls
Marin Millar Globalization Manager Developer
Division
24
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

25
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

26
ASP .NET Localization
  • v. 1.0/1.1
  • 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

27
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

lt_at_ Page cultureautofr uicultureautofr-FR
.. gt
28
Resources
  • Resource format
  • 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

29
Handling Local Resources
  • Declaratively
  • Explicit or non-explicit expressions
  • Programmatically
  • System.Web.UI.TemplateControl.GetPageResourceObjec
    t()

foo.aspx \LocalResources foo.aspx.resx
foo.aspx.fr.resx Declaratively ltasplabel
runatserver idfoo textlt
ResourcesTitle, Welcome gt /gt ltasplabel
runatserver metaResourceKeyTitleKey
gt Programmatically foo.Text
(string)GetPageResourceObject(Title, Welcome)
30
Bi-directionality
  • Direction property on ltasppanelgt
  • Marked Localizable(true)
  • Designer service generates property value in RESX
  • Can be explicitly defined
  • Can be auto assigned through non-explicit
    expression handling

ltasppanel runatserver metaresourcekeyMainTi
tle /gt ltdata nameMainTitle.Direction
type.. ContentDirectiongt ltvaluegtRightToLeftlt/
valuegt lt/datagt
31
ASP .NET Localization
Marin Millar Globalization Manager Developer
Division
32
  • 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/globalizat
    ion.aspx
  • http//msdn.microsoft.com/asp.net/community/author
    s/mlb/default.aspx?pull/library/en-us/dnaspp/html
    /aspnet-globalarchi.asp

33
Expressions
  • Declarative syntax
  • 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 lt Resourcesclass,key,default
gt ltasplabel runatserver textlt
ResourcesMainTitle gt /gt ltaspbutton
runatserver textlt ResourcesMyStrings,OK_Ke
y gt/gt Non-explicit form MetaResourceKeykeyp
refix ltasplabel runatserver
metaresourcekeyMainTitle /gt
34
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

35
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

36
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

ltasplabel runatserver metaresourcekeyMainTi
tle /gt ltdata nameMainTitle.Textgt
ltvaluegtWelcome to the sitelt/valuegt lt/datagt ltdata
nameMainTitle.Font.Bold type.. Booleangt
ltvaluegttruelt/valuegt lt/datagt
Write a Comment
User Comments (0)
About PowerShow.com