Asp.net features

Views:
 
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

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

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

Michele Leroux Bustamante : 

Michele Leroux Bustamante IDesign Inc., www.idesign.net Microsoft Regional Director Microsoft MVP – XML Web Services Published in MSDN, CoDe, more… International Speaker, INETA BEA Technical Director Events Director, IASA Program Advisor, UCSD Web Services Track Chair, SD Expo Blogs: www.dasblonde.net, www.interopwarriors.com

Agenda : 

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

What Is Globalization? : 

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

Locale/Culture : 

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

What To Localize? : 

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

Storing Localized Content : 

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

Duplicate Site Content : 

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

Duplicate Site Content : 

Web Application Resources 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

Single Content Base : 

Web Application Resources 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

Agenda : 

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

Localization Features in 2.0 : 

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

Agenda : 

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

ASP.NET 2.0 and Resources : 

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

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

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

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

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

Generating Resources : 

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

Localizing Static Content : 

Localizing Static Content The <asp:Localize> control can isolate blocks of static text for localization Participates in resource generation Based on the <asp:Literal> control, but can directly edit text in Design View <asp:Localize id=”welcomeContent” runat="server">Welcome!</asp:Localize>

Generating Local Resources : 

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

Agenda : 

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

Localization Expressions : 

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

Implicit Expressions : 

Implicit Expressions After generating resources, meta:resourcekey indicates the resource prefix for this control Resources are generated with this prefix for all localizable properties <asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" runat="server" meta:resourcekey="LinkButtonResource1">Change Culture Settings</asp:LinkButton>’

Explicit Expressions : 

Explicit Expressions Set a specific property to a specific resource entry Can come from local page resources: 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" />

Binding Expression Editor : 

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

Binding Expression Editor : 

Binding Expression Editor

Agenda : 

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

Creating Global Resources : 

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

Creating Global Resources : 

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

Improved Resource Editor : 

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

Strongly-Typed Resources : 

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

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

Global Resources, Expressions and Runtime Behavior : 

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

Agenda : 

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

Runtime Culture Selection : 

Runtime Culture Selection System.Threading.Thread.CurrentThread CurrentUICulture 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();

CultureInfo : 

CultureInfo System.Globalization.CultureInfo Encapsulates language and region

Resources and Assemblies : 

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

Resource Fallback : 

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

Resource Fallback : 

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

Culture-Specific Formatting : 

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

Automatic Culture Selection : 

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" /> <%@ Page UICulture="auto" Culture="auto">

Automatic Culture Selection : 

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

Agenda : 

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

ASP.NET Architecture : 

ASP.NET Architecture 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

Single Code/Page Base : 

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

Deployment Options : 

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

Managing User Preferences : 

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

Caching and Localization : 

Caching and Localization Caching is critical to site performance Caching localized pages requires custom caching per page @OutputCache, VaryByCustom <%@ OutputCache Duration=86400 VaryByParam=None VaryByCustom="uiCulture" %>

Caching and Localization : 

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

Handling 1.1 Resources : 

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

Culture Preferences, Caching & Deployment : 

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

Michele’s Resources : 

Michele’s Resources

Resources : 

Resources

ResourcesTech-Ed 2005 International Break-out Sessions : 

ResourcesTech-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

ResourcesTech-Ed 2005 International Cabana Talks : 

ResourcesTech-Ed 2005 International Cabana Talks Title 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

Slide 57: 

Your Feedbackis Important! Please Fill Out a Survey forThis Session on CommNet

Slide 58: 

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