Top Banner
WEB326 WEB326 ASP.NET 2.0: Going Global ASP.NET 2.0: Going Global Gets Easier! New Gets Easier! New Localization Features in Localization Features in ASP.NET 2.0 ASP.NET 2.0 Michele Leroux Bustamante Michele Leroux Bustamante Architect, IDesign Architect, IDesign Microsoft Regional Director Microsoft Regional Director
58

WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Dec 28, 2015

Download

Documents

Gwen Lawrence
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

WEB326WEB326ASP.NET 2.0: Going Global Gets ASP.NET 2.0: Going Global Gets Easier! New Localization Features Easier! New Localization Features in ASP.NET 2.0 in ASP.NET 2.0

Michele Leroux BustamanteMichele Leroux BustamanteArchitect, IDesignArchitect, IDesignMicrosoft Regional DirectorMicrosoft Regional Director

Page 2: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.
Page 3: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Michele Leroux BustamanteMichele Leroux Bustamante

Page 4: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 5: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

What Is Globalization?What Is Globalization?

Designing applications to be adapted to Designing applications to be adapted to the global marketplacethe global marketplace

Display, input, formats & conventions Display, input, formats & conventions

LocalizabilityLocalizabilitySeparate culture dependencies from code Separate culture dependencies from code

LocalizationLocalizationAdapting applications for specific marketsAdapting applications for specific markets

Content translation, feature customizationContent translation, feature customization

Changes independent of compiled sourceChanges independent of compiled source

Page 6: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Locale/CultureLocale/Culture

Language and cultural environmentLanguage and cultural environment

International Standards Organization International Standards Organization (ISO) Conventions(ISO) Conventions

Language Code: ISO 639-1 (i.e., en, fr, es)Language Code: ISO 639-1 (i.e., en, fr, es)

Country Code: ISO 3166 (i.e., CA, EC)Country Code: ISO 3166 (i.e., CA, EC)

Together, they identify culture (i.e., es-EC)Together, they identify culture (i.e., es-EC)

See See RFC 3066 – Tags for identifying RFC 3066 – Tags for identifying languageslanguages

Custom cultures are sometimes Custom cultures are sometimes necessarynecessary

Page 7: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

What To Localize?What To Localize?

Static (hard-coded) application contentStatic (hard-coded) application contentMenu/control captions, Web content, XMLMenu/control captions, Web content, XML

Dynamic application contentDynamic application contentDatabase, XML, otherDatabase, XML, other

Graphical contentGraphical content

Filenames, connection strings, queriesFilenames, connection strings, queries

Page 8: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Storing Localized ContentStoring Localized Content

Deployment architecture is affected by Deployment architecture is affected by location of localized application location of localized application contentcontent

Resources, file system, database,Resources, file system, database,external applicationsexternal applications

Choices influenced by application typeChoices influenced by application typeMicrosoft Windows versus Web Microsoft Windows versus Web

And by business requirementsAnd by business requirementsFrequency of culture translationsFrequency of culture translations

Ease of translation processEase of translation process

Frequency of application maintenanceFrequency of application maintenance

Page 9: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Database ContentDatabase Content

Duplicate Site ContentDuplicate Site Content

GlobalWeb.dllGlobalWeb.dllGlobalWeb.dllGlobalWeb.dll

ProductsProducts

GlobalWebGlobalWeb \bin\bin

Global.asaxGlobal.asax

Web.configWeb.config

logo.giflogo.gif

page page and user and user control control contentcontent

Page 10: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Database ContentDatabase Content

Duplicate Site ContentDuplicate Site Content

GlobalWeb.dllGlobalWeb.dllGlobalWeb.dllGlobalWeb.dll

ProductsProducts

Products_en-CAProducts_en-CA

Products_esProducts_es

GlobalWebGlobalWeb

\en-CA\en-CA

\bin\bin

\es\es

Global.asaxGlobal.asax

Web.configWeb.config

logo.giflogo.gif

logo.en-CA.giflogo.en-CA.gif

logo.es.giflogo.es.gif

page page and user and user control control contentcontent

translated translated page and user page and user control control contentcontent

Page 11: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Database ContentDatabase Content

Single Content BaseSingle Content Base

GlobalWeb.dllGlobalWeb.dllGlobalWeb.dllGlobalWeb.dll

ProductsProductsProducts_en-CAProducts_en-CAProducts_esProducts_es

GlobalWebGlobalWeb \bin\bin

Global.asaxGlobal.asax

Web.configWeb.config

logo.giflogo.gif

logo.en-CA.giflogo.en-CA.gif

logo.es.giflogo.es.gif

Satellite AssembliesSatellite Assemblies

\en\en

\en-CA\en-CA

\es\es

GlobalWeb.en.dllGlobalWeb.en.dllGlobalWeb.en.dllGlobalWeb.en.dll

GlobalWeb.en-CA.dllGlobalWeb.en-CA.dllGlobalWeb.en-CA.dllGlobalWeb.en-CA.dll

GlobalWeb.es.dllGlobalWeb.es.dllGlobalWeb.es.dllGlobalWeb.es.dll

list.en-CA.xmllist.en-CA.xml

list.es.xmllist.es.xml

resourcesresourcesresourcesresources

resourcesresources

resourcesresources

translated translated file file contentcontent

Page 12: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 13: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Localization Features in 2.0Localization Features in 2.0

Web Forms resource generatorWeb Forms resource generator

Localization expressions Localization expressions

Strongly-typed resourcesStrongly-typed resources

Improved Resource EditorImproved Resource Editor

ResourceManager lifetime managementResourceManager lifetime management

Automatic culture selectionAutomatic culture selection

New Microsoft ASP.NET deployment New Microsoft ASP.NET deployment optionsoptions

New resource provider modelNew resource provider model

Page 14: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 15: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ASP.NET 2.0 and ResourcesASP.NET 2.0 and Resources

XML Resources (*.resx)XML Resources (*.resx)

Generated for master pages, content Generated for master pages, content pages, and user controlspages, and user controls

Accessible through page or control Accessible through page or control properties, declarative properties, declarative expressions, expressions, or other APIsor other APIs

Type-safe global resources Type-safe global resources

Set multiple localized Set multiple localized control control properties in a properties in a single single commandcommand

Page 16: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ASP.NET 2.0 and Resources (cont’d)ASP.NET 2.0 and Resources (cont’d)

App_LocalResourcesApp_LocalResourcesGenerated automatically or by handGenerated automatically or by handPer page, controlPer page, control

App_GlobalResources App_GlobalResources Manual generationManual generationShared, strongly-typedShared, strongly-typed

Pre-compile or deploy Pre-compile or deploy source source files and let the files and let the resource build resource build

provider handle provider handle the rest the rest

Page 17: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ASP.NET 2.0 and Resources (cont’d)ASP.NET 2.0 and Resources (cont’d)

ResourceManager lifecycle is handled ResourceManager lifecycle is handled automaticallyautomatically

Resource providers are cached along Resource providers are cached along with specific resource manager with specific resource manager instances per local or global resourceinstances per local or global resource

Default resource and satellite Default resource and satellite assemblies are loaded into application assemblies are loaded into application domain, like providers, and readily domain, like providers, and readily accessibleaccessible

ResourceManager is still thread-safeResourceManager is still thread-safe

Page 18: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Generating ResourcesGenerating Resources

From Design View, select Generate From Design View, select Generate Local Resource from the Tools menuLocal Resource from the Tools menu

Localizable properties for server Localizable properties for server controls are stuffed into resourcescontrols are stuffed into resources

Non-localizable properties can be Non-localizable properties can be manually insertedmanually inserted

Localization expressions are generated Localization expressions are generated for each server controlfor each server control

Page parser turns expressions into code Page parser turns expressions into code to set properties from resourcesto set properties from resources

Page 19: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Localizing Static ContentLocalizing Static Content

The <asp:Localize> control can isolate The <asp:Localize> control can isolate blocks of static text for localizationblocks of static text for localization

Participates in resource generationParticipates in resource generation

Based on the <asp:Literal> control, but Based on the <asp:Literal> control, but can directly edit text in Design Viewcan directly edit text in Design View

<asp:Localize id=”welcomeContent” runat="server">Welcome!</asp:Localize>

Page 20: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.
Page 21: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Generating Local ResourcesGenerating Local Resources

Michele Leroux BustamanteMichele Leroux BustamanteArchitect, IDesignArchitect, IDesignMicrosoft Regional DirectorMicrosoft Regional Director

Page 22: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 23: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Localization ExpressionsLocalization Expressions

ASP.NET supports new declarative ASP.NET supports new declarative binding expressions for connection binding expressions for connection strings, application settings and strings, application settings and resourcesresources

Extensible for custom bindingsExtensible for custom bindings

Automatically applied when resources Automatically applied when resources are generated for a pageare generated for a page

Can hand-edit to control where resources Can hand-edit to control where resources are drawn fromare drawn from

Page 24: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Implicit ExpressionsImplicit Expressions

After generating resources, After generating resources, meta:resourcekey indicates the meta:resourcekey indicates the resource prefix for this controlresource prefix for this control

Resources are generated with this Resources are generated with this prefix for all localizable propertiesprefix for all localizable properties

<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" runat="server" meta:resourcekey="LinkButtonResource1">Change Culture Settings</asp:LinkButton>’

Page 25: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Explicit ExpressionsExplicit Expressions

Set a specific property to a specific Set a specific property to a specific resource entryresource entry

Can come from local page resources:Can come from local page resources:

Or, from a global resource:Or, from a global resource:

<asp:ImageButton id="btnIDesign" Runat="server" ImageUrl="~/Images/idesignlogo.jpg" AlternateText='<%$ Resources: MissionStatement %>‘ PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />

<asp:ImageButton id="btnIDesign" Runat="server" ImageUrl="~/Images/idesignlogo.jpg" AlternateText='<%$ Resources: Glossary, MissionStatement %>‘ PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />

Page 26: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Binding Expression EditorBinding Expression Editor

Bindings can be set through the Bindings can be set through the Properties window via Expressions Properties window via Expressions editor dialogeditor dialog

ClassKey specifies a global resource if ClassKey specifies a global resource if applicable, omit for local resourcesapplicable, omit for local resources

ResourceKey specifies the resource ResourceKey specifies the resource entry to apply to the control propertyentry to apply to the control property

Page 27: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Binding Expression EditorBinding Expression Editor

Page 28: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 29: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Creating Global ResourcesCreating Global Resources

Add a Resources file to the applicationAdd a Resources file to the application

Will be placed in a special Will be placed in a special App_GlobalResources directoryApp_GlobalResources directory

Page 30: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Creating Global ResourcesCreating Global Resources

Add resources through the integrated Add resources through the integrated Resource EditorResource Editor

Apply them to server controls using Apply them to server controls using explicit expressionsexplicit expressions

Or, write custom code to retrieve them Or, write custom code to retrieve them at runtimeat runtime

<asp:ImageButton id="btnIDesign" Runat="server" ImageUrl="~/Images/idesignlogo.jpg" AlternateText='<%$ Resources: Glossary, MissionStatement %>‘ PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />

Page 31: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Improved Resource EditorImproved Resource Editor

Integrated with Visual StudioIntegrated with Visual Studio

Visually categorize resources by their Visually categorize resources by their data typedata type

More friendly interfaceMore friendly interface

Create new images/icons in placeCreate new images/icons in place

Page 32: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Strongly-Typed ResourcesStrongly-Typed Resources

Global resources generate a type-safe Global resources generate a type-safe class accessible via global Properties class accessible via global Properties objectobject

Page 33: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

class Resources {private static System.Resources.ResourceManager _resMgr;private static System.Globalization.CultureInfo _resCulture;

/*FamANDAssem*/ internal Resources() {}

[System.ComponentModel.EditorBrowsableAttribute(…)]public static System.Resources.ResourceManager ResourceManager {…}

[System.ComponentModel.EditorBrowsableAttribute(…)]

public static System.Globalization.CultureInfo Culture {…}

public static System.Drawing.Bitmap flag { get { return ((System.Drawing.Bitmap)(ResourceManager.GetObject("flag", _resCulture))); } } }

Page 34: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Global Resources, Expressions Global Resources, Expressions and Runtime Behaviorand Runtime Behavior

Michele Leroux BustamanteMichele Leroux BustamanteArchitect, IDesignArchitect, IDesignMicrosoft Regional DirectorMicrosoft Regional Director

Page 35: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 36: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Runtime Culture SelectionRuntime Culture Selection

System.Threading.Thread.CurrentThreadSystem.Threading.Thread.CurrentThread

CurrentUICultureCurrentUICultureAffects resource selectionAffects resource selection

Defaults to system UI language, or:Defaults to system UI language, or:

CurrentCultureCurrentCultureAffects formatting and conventionsAffects formatting and conventions

Defaults to user locale, can be changed:Defaults to user locale, can be changed:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");

Thread.CurrentThread.CurrentCulture = new CultureInfo("es");DateTime dt = DateTime.Now;String s = dt.ToLongDateString();

Page 37: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

CultureInfoCultureInfo

System.Globalization.CultureInfoSystem.Globalization.CultureInfoEncapsulates language and regionEncapsulates language and region

Page 38: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Resources and AssembliesResources and Assemblies

Satellite assembliesSatellite assembliesGenerated from localized resourcesGenerated from localized resources

Hub and spoke modelHub and spoke model

Pre-compiled or JIT-compiled Pre-compiled or JIT-compiled for ASP.NETfor ASP.NET

Resource build providerResource build provider

ResourceManager handles resource ResourceManager handles resource fallback to retrieve culture-specific fallback to retrieve culture-specific entries at runtimeentries at runtime

Page 39: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Resource FallbackResource Fallback

Best match is current thread’sBest match is current thread’sUI cultureUI culture

I.e., en-CA, en-USI.e., en-CA, en-US

Neutral parent culture is next best fitNeutral parent culture is next best fitI.e., enI.e., en

Last resort is Last resort is default fromdefault frommain assemblymain assembly

(default)(default)

en-CA

en-US

en

(default)

Page 40: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Resource FallbackResource Fallback

Identify the default resource culture Identify the default resource culture [assembly: NeutralResourcesLanguageAttribute("en")][assembly: NeutralResourcesLanguageAttribute("en")]

Default resources will be used instead Default resources will be used instead of searching for satellite assemblyof searching for satellite assembly

en-CA

en-US

en

(default)

Page 41: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Culture-Specific FormattingCulture-Specific Formatting

System.GlobalizationSystem.Globalization

Utility classes support formatting, Utility classes support formatting, sorting and conversion by culturesorting and conversion by culture

Formatting ClassesFormatting ClassesSorting: SortKey, CompareInfoSorting: SortKey, CompareInfo

String comparison: CompareInfoString comparison: CompareInfo

Date and time: DateTimeFormatInfoDate and time: DateTimeFormatInfo

Numbers: NumberFormatInfoNumbers: NumberFormatInfo

Calendar data: CalendarCalendar data: Calendar

Page 42: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Automatic Culture SelectionAutomatic Culture Selection

Based on browser language settingsBased on browser language settings

Application or page scopeApplication or page scope

Can specify default cultureCan specify default cultureI.e., “auto:en-US”I.e., “auto:en-US”

<globalization requestEncoding=“utf-8" responseEncoding=“utf-8" fileEncoding=“utf-8" culture=“auto:en-US" uiCulture=“auto" />

<%@ Page UICulture="auto" Culture="auto">

Page 43: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Automatic Culture SelectionAutomatic Culture Selection

Michele Leroux BustamanteMichele Leroux BustamanteArchitect, IDesignArchitect, IDesignMicrosoft Regional DirectorMicrosoft Regional Director

Page 44: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

AgendaAgenda

Localization and the WebLocalization and the Web

New Localization Features in 2.0New Localization Features in 2.0

Generating Local ResourcesGenerating Local Resources

Localization ExpressionsLocalization Expressions

Global Resources and Type SafetyGlobal Resources and Type Safety

Runtime Culture SelectionRuntime Culture Selection

ASP.NET ArchitectureASP.NET Architecture

Page 45: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ASP.NET ArchitectureASP.NET Architecture

Single code/page base is easy with 2.0Single code/page base is easy with 2.0No duplicate Web content per cultureNo duplicate Web content per culture

Generated page resourcesGenerated page resourcesMake consuming resources per page easyMake consuming resources per page easy

Type-safe shared resourcesType-safe shared resourcesMake consuming common resources easyMake consuming common resources easy

ResourceManager lifecycle ResourceManager lifecycle Less code required, runtime handles itLess code required, runtime handles it

Page 46: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Single Code/Page BaseSingle Code/Page Base

Low impact translationsLow impact translations

Improved productivityImproved productivityFewer errorsFewer errors

Less overall development effortLess overall development effort

IssuesIssuesManaging iterations with translatorsManaging iterations with translators

Giving translators access to data sourcesGiving translators access to data sources

Working with Web designersWorking with Web designers

Page 47: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Deployment OptionsDeployment Options

Deploy application sourceDeploy application sourceResources (.resx) are dynamically Resources (.resx) are dynamically compiled into satellite assembliescompiled into satellite assemblies

Updates are not version controlledUpdates are not version controlled

Source is not protectedSource is not protected

Deploy pre-compiled applicationDeploy pre-compiled applicationAssemblies pre-generated, including a Assemblies pre-generated, including a local and global resource assembly and local and global resource assembly and its associated satellite assembliesits associated satellite assemblies

Better version control and IP protectionBetter version control and IP protection

Page 48: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Managing User PreferencesManaging User Preferences

Automatic culture selection is Automatic culture selection is inadequate for enterprise applicationsinadequate for enterprise applications

Culture selection options:Culture selection options:Auto (for default only)Auto (for default only)

UI selection UI selection

User registrationUser registration

Preferences should be persisted:Preferences should be persisted:Transient solutions include cookies or Transient solutions include cookies or user sessionuser session

Persistent solutions should leverage profiles or Persistent solutions should leverage profiles or data storagedata storage

Page 49: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Caching and LocalizationCaching and Localization

Caching is critical to site performanceCaching is critical to site performance

Caching localized pages requires Caching localized pages requires custom caching per pagecustom caching per page

@OutputCache, VaryByCustom@OutputCache, VaryByCustom

<%@ OutputCache Duration=86400 VaryByParam=None VaryByCustom="uiCulture" %>

Page 50: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Caching and LocalizationCaching and Localization

GetVaryByCustomString must have GetVaryByCustomString must have access to the user’s preferred cultureaccess to the user’s preferred culture

Initialize the thread earlier in page cycleInitialize the thread earlier in page cycleNote:Note: Session and Profile not available Session and Profile not available

public override string GetVaryByCustomString(HttpContext context, string custom){ if (string.Compare(custom, "uiCulture", true, System.Globalization.CultureInfo.InvariantCulture) == 0 && System.Threading.Thread.CurrentThread.CurrentUICulture != null) { return System.Threading.Thread.CurrentThread.CurrentUICulture.Name; } else return base.GetVaryByCustomString(context, custom);}

Page 51: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Handling 1.1 ResourcesHandling 1.1 Resources

By default, localization expressions By default, localization expressions and resource providers do not interact and resource providers do not interact with 1.1 resourceswith 1.1 resources

Can port your 1.1 solution to data binding Can port your 1.1 solution to data binding expressions and ResourceManager expressions and ResourceManager lifecycle managementlifecycle management

Custom expression builders and Custom expression builders and resource providers can helpresource providers can help

Page 52: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Culture Preferences, Caching & Culture Preferences, Caching & DeploymentDeployment

Michele Leroux BustamanteMichele Leroux BustamanteArchitect, IDesignArchitect, IDesignMicrosoft Regional DirectorMicrosoft Regional Director

Page 53: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Michele’s ResourcesMichele’s Resources

Michele’s Globalization Site: Michele’s Globalization Site: http://www.dotnetdashboard.net/sessions/globalization.aspx

Michele’s Blog: Michele’s Blog: http://www.dasblonde.net

IDesign: IDesign: http://www.idesign.net

Localization Partner Program: Localization Partner Program: http://www.vsippartners.com/programs/localization

Page 54: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ResourcesResources

General guidelines on internationalization:General guidelines on internationalization: http://www.microsoft.com/globaldev

General questions:General questions: [email protected]

Developing International Software:Developing International Software: (available here at the Tech-Ed store)(available here at the Tech-Ed store)

Page 55: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ResourcesResourcesTech-Ed 2005 International Break-out SessionsTech-Ed 2005 International Break-out Sessions

TitleTitleCodeCode

ASP.NET 2.0: Going GlobalASP.NET 2.0: Going Global Gets Easier! New Localization Features in Gets Easier! New Localization Features in ASP.NET 2.0ASP.NET 2.0

WEB326WEB326

Deploying Office 2003Deploying Office 2003 in a Multilingual Environment in a Multilingual EnvironmentDSK345DSK345

Deploying Windows XPDeploying Windows XP in a Multilingual Environment in a Multilingual EnvironmentDSK350DSK350

Databases for the World:Databases for the World: Best Practices for Search in Multilingual Data Best Practices for Search in Multilingual Data Sets Using SQL Server Collation for Sorting and IndexingSets Using SQL Server Collation for Sorting and Indexing

DBA319DBA319

Microsoft Business SolutionsMicrosoft Business Solutions––Axapta:Axapta: A Truly Global Business Application A Truly Global Business ApplicationBAP347BAP347

Supporting East Asian LanguagesSupporting East Asian Languages in Global Exchange Deployments in Global Exchange DeploymentsMSG369MSG369

.NET Framework: Think Global!.NET Framework: Think Global! Custom Cultures and International Data Custom Cultures and International DataDEV323DEV323

Databases for the World:Databases for the World: Designing Multilingual Databases Using SQL Designing Multilingual Databases Using SQL Server 2005Server 2005

DAT290DAT290

Planning a Global Release:Planning a Global Release: Many countries, Many Languages, One Process Many countries, Many Languages, One ProcessARC303ARC303

Page 56: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

ResourcesResourcesTech-Ed 2005 International Cabana TalksTech-Ed 2005 International Cabana Talks

Dr. International’s ClinicDr. International’s Clinic

Booth in the Community Cabana International Experts available all week long

TitleTitleCodeCode

Custom Cultures in Whidbey: Custom Cultures in Whidbey: An In-Depth DiscussionAn In-Depth DiscussionDEVC21DEVC21

Advanced Localization ArchitectureAdvanced Localization ArchitectureDEVC19DEVC19

Windows XP MUI:Windows XP MUI: Keeping it Localized & Secure Keeping it Localized & SecureDSKC07DSKC07

Meet the Speakers From ARC303: Meet the Speakers From ARC303: Planning a Global ReleasePlanning a Global ReleaseARCC04ARCC04

Page 57: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

Your FeedbackYour Feedbackis Important!is Important!Please Fill Out a Survey forPlease Fill Out a Survey forThis Session on CommNetThis Session on CommNet

Page 58: WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.