Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional."— Presentation transcript:

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 Director

2

3 Michele Leroux Bustamante

4 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

5 What Is Globalization? Designing applications to be adapted to the global marketplace Display, input, formats & conventions Localizability Separate culture dependencies from code Localization Adapting applications for specific markets Content translation, feature customization Changes independent of compiled source

6 Locale/Culture Language and cultural environment International Standards Organization (ISO) Conventions Language Code: ISO 639-1 (i.e., en, fr, es) Country Code: ISO 3166 (i.e., CA, EC) Together, they identify culture (i.e., es-EC) See RFC 3066 – Tags for identifying languages Custom cultures are sometimes necessary

7 What To Localize? Static (hard-coded) application content Menu/control captions, Web content, XML Dynamic application content Database, XML, other Graphical content Filenames, connection strings, queries

8 Storing Localized Content Deployment architecture is affected by location of localized application content Resources, file system, database, external applications Choices influenced by application type Microsoft Windows versus Web And by business requirements Frequency of culture translations Ease of translation process Frequency of application maintenance

9 Database Content Duplicate Site Content GlobalWeb.dll Products GlobalWeb\bin Global.asax Web.config logo.gif page and user control content

10 Database Content Duplicate Site Content GlobalWeb.dll Products Products_en-CA Products_es GlobalWeb \en-CA \bin \es Global.asax Web.config logo.gif logo.en-CA.gif logo.es.gif page and user control content translated page and user control content

11 Database Content Single Content Base GlobalWeb.dll Products Products_en-CA Products_es GlobalWeb\bin Global.asax Web.config logo.gif logo.en-CA.gif logo.es.gif Satellite Assemblies \en \en-CA \es GlobalWeb.en.dll GlobalWeb.en-CA.dll GlobalWeb.es.dll list.en-CA.xml list.es.xml resources resources resources resources translated file content

12 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

13 Localization Features in 2.0 Web Forms resource generator Localization expressions Strongly-typed resources Improved Resource Editor ResourceManager lifetime management Automatic culture selection New Microsoft ASP.NET deployment options New resource provider model

14 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

15 ASP.NET 2.0 and Resources XML Resources (*.resx) Generated for master pages, content pages, and user controls Accessible through page or control properties, declarative expressions, or other APIs Type-safe global resources Set multiple localized control properties in a single command

16 ASP.NET 2.0 and Resources (cont’d) App_LocalResources Generated automatically or by hand Per page, control App_GlobalResources Manual generation Shared, strongly-typed Pre-compile or deploy source files and let the resource build provider handle the rest

17 ASP.NET 2.0 and Resources (cont’d) ResourceManager lifecycle is handled automatically Resource providers are cached along with specific resource manager instances per local or global resource Default resource and satellite assemblies are loaded into application domain, like providers, and readily accessible ResourceManager is still thread-safe

18 Generating Resources From Design View, select Generate Local Resource from the Tools menu Localizable properties for server controls are stuffed into resources Non-localizable properties can be manually inserted Localization expressions are generated for each server control Page parser turns expressions into code to set properties from resources

19 Localizing Static Content The control can isolate blocks of static text for localization Participates in resource generation Based on the control, but can directly edit text in Design View Welcome!

20

21 Generating Local Resources Michele Leroux Bustamante Architect, IDesign Microsoft Regional Director

22 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

23 Localization Expressions ASP.NET supports new declarative binding expressions for connection strings, application settings and resources Extensible for custom bindings Automatically applied when resources are generated for a page Can hand-edit to control where resources are drawn from

24 Implicit Expressions After generating resources, meta:resourcekey indicates the resource prefix for this control Resources are generated with this prefix for all localizable properties Change Culture Settings ’

25 Explicit Expressions Set a specific property to a specific resource entry Can come from local page resources: Or, from a global resource: ‘ PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />

26 Binding Expression Editor Bindings can be set through the Properties window via Expressions editor dialog ClassKey specifies a global resource if applicable, omit for local resources ResourceKey specifies the resource entry to apply to the control property

27 Binding Expression Editor

28 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

29 Creating Global Resources Add a Resources file to the application Will be placed in a special App_GlobalResources directory

30 Creating Global Resources Add resources through the integrated Resource Editor Apply them to server controls using explicit expressions Or, write custom code to retrieve them at runtime ‘ PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />

31 Improved Resource Editor Integrated with Visual Studio Visually categorize resources by their data type More friendly interface Create new images/icons in place

32 Strongly-Typed Resources Global resources generate a type-safe class accessible via global Properties object

33 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))); }

34 Global Resources, Expressions and Runtime Behavior Michele Leroux Bustamante Architect, IDesign Microsoft Regional Director

35 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

36 Runtime Culture Selection System.Threading.Thread.CurrentThreadCurrentUICulture Affects resource selection Defaults to system UI language, or: CurrentCulture Affects formatting and conventions 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();

37 CultureInfo System.Globalization.CultureInfo Encapsulates language and region

38 Resources and Assemblies Satellite assemblies Generated from localized resources Hub and spoke model Pre-compiled or JIT-compiled for ASP.NET Resource build provider ResourceManager handles resource fallback to retrieve culture-specific entries at runtime

39 Resource Fallback Best match is current thread’s UI culture I.e., en-CA, en-US Neutral parent culture is next best fit I.e., en Last resort is default from main assembly (default) en-CA en-US en (default)

40 Resource Fallback Identify the default resource culture [assembly: NeutralResourcesLanguageAttribute("en")] Default resources will be used instead of searching for satellite assembly en-CA en-US en (default)

41 Culture-Specific Formatting System.Globalization Utility classes support formatting, sorting and conversion by culture Formatting Classes Sorting: SortKey, CompareInfo String comparison: CompareInfo Date and time: DateTimeFormatInfo Numbers: NumberFormatInfo Calendar data: Calendar

42 Automatic Culture Selection Based on browser language settings Application or page scope Can specify default culture I.e., “auto:en-US” <globalization requestEncoding=“utf-8" responseEncoding=“utf-8" fileEncoding=“utf-8" culture=“auto:en-US" uiCulture=“auto" />

43 Automatic Culture Selection Michele Leroux Bustamante Architect, IDesign Microsoft Regional Director

44 Agenda Localization and the Web New Localization Features in 2.0 Generating Local Resources Localization Expressions Global Resources and Type Safety Runtime Culture Selection ASP.NET Architecture

45 Single code/page base is easy with 2.0 No duplicate Web content per culture Generated page resources Make consuming resources per page easy Type-safe shared resources Make consuming common resources easy ResourceManager lifecycle Less code required, runtime handles it

46 Single Code/Page Base Low impact translations Improved productivity Fewer errors Less overall development effort Issues Managing iterations with translators Giving translators access to data sources Working with Web designers

47 Deployment Options Deploy application source Resources (.resx) are dynamically compiled into satellite assemblies Updates are not version controlled Source is not protected Deploy pre-compiled application Assemblies pre-generated, including a local and global resource assembly and its associated satellite assemblies Better version control and IP protection

48 Managing User Preferences Automatic culture selection is inadequate for enterprise applications Culture selection options: Auto (for default only) UI selection User registration Preferences should be persisted: Transient solutions include cookies or user session Persistent solutions should leverage profiles or data storage

49 Caching and Localization Caching is critical to site performance Caching localized pages requires custom caching per page @OutputCache, VaryByCustom

50 Caching and Localization GetVaryByCustomString must have access to the user’s preferred culture Initialize the thread earlier in page cycle Note: 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); }

51 Handling 1.1 Resources By default, localization expressions and resource providers do not interact with 1.1 resources Can port your 1.1 solution to data binding expressions and ResourceManager lifecycle management Custom expression builders and resource providers can help

52 Culture Preferences, Caching & Deployment Michele Leroux Bustamante Architect, IDesign Microsoft Regional Director

53 Michele’s Resources Michele’s Globalization Site: http://www.dotnetdashboard.net/sessions/globalizatio n.aspx http://www.dotnetdashboard.net/sessions/globalizatio n.aspx http://www.dotnetdashboard.net/sessions/globalizatio n.aspx Michele’s Blog: http://www.dasblonde.net http://www.dasblonde.net IDesign: http://www.idesign.net http://www.idesign.net Localization Partner Program: http://www.vsippartners.com/programs/localization http://www.vsippartners.com/programs/localization

54 Resources General guidelines on internationalization: General guidelines on internationalization: http://www.microsoft.com/globaldevhttp://www.microsoft.com/globaldev General questions: General questions: drintl@microsoft.comdrintl@microsoft.com Developing International Software: (available here at the Tech-Ed store)

55 Resources Tech-Ed 2005 International Break-out Sessions Title Code ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 WEB326 Deploying Office 2003 in a Multilingual Environment DSK345 Deploying Windows XP in a Multilingual Environment DSK350 Databases for the World: Best Practices for Search in Multilingual Data Sets Using SQL Server Collation for Sorting and Indexing DBA319 Microsoft Business Solutions–Axapta: A Truly Global Business Application BAP347 Supporting East Asian Languages in Global Exchange Deployments MSG369.NET Framework: Think Global! Custom Cultures and International Data DEV323 Databases for the World: Designing Multilingual Databases Using SQL Server 2005 DAT290 Planning a Global Release: Many countries, Many Languages, One Process ARC303

56 Resources Tech-Ed 2005 International Cabana Talks Dr. International’s Clinic Booth in the Community Cabana International Experts available all week longTitle Code Custom Cultures in Whidbey: An In-Depth Discussion DEVC21 Advanced Localization Architecture DEVC19 Windows XP MUI: Keeping it Localized & Secure DSKC07 Meet the Speakers From ARC303: Planning a Global Release ARCC04

57 Your Feedback is Important! Please Fill Out a Survey for This Session on CommNet

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


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

Similar presentations


Ads by Google