Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation.

Similar presentations

Presentation on theme: "Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation."— Presentation transcript:

1 Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation

2 Agenda  Resource Improvements  Strongly Typed Resources  Fallback to Satellite Assembly  Editing Resources  ASP.NET Localization  Detecting the Browser Language  Declarative Localization Model with designer support  Extensibility  Deployment  Bidirectional Web Pages  Smart Client Applications  Windows Forms  Table Layout/Grid Layout Controls  Bidirectional Languages  Performance Improvements  ClickOnce Deployment

3 Visual Studio and.NET Framework Versions Visual Studio.NET.NET Framework v1.0 Visual Studio.NET 2003.NET Framework v1.1 Visual Studio 2005 (code name: Whidbey).NET Framework v2.0 (code name: Whidbey)

4 Strongly Typed Resources  Resources have types  Strings  Boolean  Images  Audio Files  …  Strongly Typed Resources  What are they?  Provide ability to creates classes containing read-only properties for resources  Benefits:  Eliminates mismatches between code and resource identifiers  Provides Intellisense on resource identifiers  ResourceManager is created for you  No need to cast objects to other types

5 Resources Then and Now private ResourceManager rm; rm = new ResourceManager("MyImages", this.GetType().Assembly); PictureBox.Image = (System.Drawing.Image)rm.GetObject("MyImage"); PictureBox.Image = ResourceFilename.MyImage;.NET Framework v1.0/v1.1.NET Framework v2.0

6 Fallback To Satellite Assembly  Fallback  Best fit UI language for user (CurrentUICulture)  Example: fr-CA → fr → fallback (e.g. de)  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  [assembly: NeutralResourcesLanguageAttribute("de", UltimateResourceFallbackLocation.Satellite)]  Clean separation of code and user interface  Useful for servicing  Can potentially reduce download size for updates

7 Editing Resources  New Resource Editor  Integrated in Visual Studio 2005  For.resx format  Uses link syntax for complex type resources (images, sounds, …)  XML editors and localization tools can still be used  More on Windows Forms and ASP.NET resource editing later

8 Creating and Using Resources

9 ASP.NET Localization  v. 1.0/1.1 .NET resource model can be used  No design time assistance  v. 2.0  Uses.NET resource model  Provides a simple declarative model for localization  Automatic generation of resources in designer  Editing of resources using the resource editor  Server side compilation of.resx files  Auto-detection of browser culture

10 Detecting the Browser Language  HTTP Accept-Language header  v 1.0/1.1  Write code to detect browser language  Specify preferred culture in web.config, page or code  2.0  Use “auto” for automatically detecting browser language  Can override in InitializeCulture()  It is still possible to specify preferred culture in web.config, page or code

11 ASP.NET Resources  Local Resources  Use for page resources  Stored in \App_LocalResources folder  Generated through the designer  Tools/Generate Local Resources command used in design view of the page  Global Application Resources  Use for global strings or binary types  Stored in \App_GlobalResources folder  Strongly-typed, available to all pages through Resources member  Default Resource format  Author.resx in the resource or XML editor  Other formats possible through extensibility

12 Retrieving Resources  Declaratively  Explicit or implicit expressions  Programmatic  GetLocalResourceObject()/GetGlobalResourceObject()  System.Web.UI.TemplateControl Class  System.Web.HttpContext Class foo.aspx \App_LocalResources foo.aspx.resx Declaratively: " /> Programmatically: foo.Text = (string)GetLocalResourceObject(“foo");

13 Expressions  Declarative syntax  Access local or global resources  Interpreted at parse time  Explicit and implicit forms  Can be mixed, but should not collide  Designer creates implicit expression syntax  Explicit expressions can be edited in Expressions property of controls Explicit form: ” /> Implicit form: meta:ResourceKey=“keyprefix”

14 Extensibility  Other resource formats  Databases  Existing XML formats  …  Option 1: Localization expressions can be extended  Subclass ResourceProviderFactory  Allows design-time support for custom resource formats  Option 2: Create expression builder for new resource format  Subclass System.Web.Compilation.ExpressionBuilder  Design-time support only through ExpressionEditor  Deployment of e.g. a database is more difficult

15 Deployment  ASP.NET v2.0 has 3 compilation models  Uncompiled  Source files including.resx files are copied to server  Resources are compiled on server  Compiled resources are cached on first use  Precompiled excluding markup  Deploy.resx/.aspx files like in uncompiled case  Page design changeable  Global resource satellite assemblies precompiled  Precompiled including markup  Page design cannot be changed  Everything precompiled into assemblies  Additional languages can be added in all 3 models  Application domain needs to be restarted

16 Bidirectional Web Pages  Direction property on  Can be explicitly defined  Can be loaded using a resource expression  Useful for mixed left-to-right/right-to-left pages  Full right-to-left pages  Set DIR attribute on HTML tag using an explicit resource expression RightToLeft

17 ASP.NET Localization

18 Windows Forms Localization v1.0/v1.1  Each form has a Localizable property  Creates single.resx file for default resources  Each form has Language property  Creates one additional.resx file per selected language  Edit source/localized.resx files in  Visual Studio Windows Forms designer  XML editor  WinRes tool (.NET Framework SDK tool)  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

19 Windows Forms Localization v2.0  Localizable/Language properties remain the same  One.resx file per form per language  Edit source/localized.resx files in  Visual Studio Windows Forms designer  WinRes tool (.NET Framework SDK tool)  Visual Studio Resource Editor  XML editor  Images  Linked into.resx files rather than serialized  Default to application-wide.resx file  New code generation using the ComponentResourceManager improves performance  New layout functionality reduces resizing during localization  Deploy Click Once projects in any language

20 Localize Without Resizing  v1.0/v1.1  Use docking and anchoring properties  new layout controls in v2.0  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

21 RightToLeft Languages  RightToLeft property (v 1.0/v 1.1/v 2.0)  Determines reading order for text  Affects layout for some controls  RightToLeftLayout (v 2.0)  Determines layout of controls  Form, TabControl, TreeView, ListView, TrackBar, ProgressBar, MonthCalendar and DateTimePicker  Does not inherit down control hierarchy  Controls support full “mirroring”  Set both RightToLeft and RightToLeftLayout  Determining text direction for culture  CultureInfo.TextInfo.IsRightToLeft

22 Click Once  New deployment mechanism  versioning  update service  installation over the web  …  Deploy multiple languages from a single project  Language property determines  language satellite assemblies  language external dependencies  ClickOnce language resources (.xml files)  Can extend ClickOnce resource languages by localizing setup.xml

23 Layout Controls and ClickOnce

24 References  Visual Studio 2005/.NET Framework v2.0   Microsoft Globaldev website   Newsgroup  news:microsoft.public.dotnet.internationalization news:microsoft.public.dotnet.internationalization  Blogs    


26 Appendix ASP.NET Localization Expressions

27 Implicit 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

28 Implicit 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 Welcome to the site true

29 Explicit Expressions  Used on any control or object property  Fine-grained handling for properties which are not localizable by default  Can be used for HTML attributes  Access global 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

Download ppt "Creating Multi-lingual Applications and Websites with Microsoft Visual Studio 2005 Achim Ruopp International Program Manager Microsoft Corporation."

Similar presentations

Ads by Google