10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle...
-
Upload
pierce-pierce -
Category
Documents
-
view
215 -
download
1
Transcript of 10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle...
10 – 12 APRIL 2005 Riyadh, Saudi Arabia10 – 12 APRIL 2005 Riyadh, Saudi Arabia
Building multi-lingual ASP.Net application that handle western languages and Arabic
with a single code base.
Building multi-lingual ASP.Net application that handle western languages and Arabic
with a single code base.
Abdellatif TarhineMicrosoft Regional Director for North Africa
AgendaAgendaInternationalizing Your Application
What's New in APS.NET 2.0
Culture-sensitive Formatting
LocalizationResource Expressions
Local and Global Resources
Implicit Expressions to Local Resources
Explicit Expressions to Local Resources
Programmatic Access to Global Resources
Localizing Static Content
Storing Language Preferences
ASP.NET 2.0 Localization Features ASP.NET 2.0 Localization Features
More tools built in to the Microsoft Visual Studio .NET 2005 environment.
New runtime capabilities.
Rich new programming API specifically targeting localization requirements.
Specifying Cultures Specifying Cultures
How do you specify a culture?
there is an Internet standard called RFC 1766 that specifies codes for cultures
ar-SA—Arabic - Saudi Arabia
en-GB—English—United Kingdom
en-US—English—United States
fr-FR—French - France
zh-CN—Chinese - China
the first part (lower case) specifies the language, and the second part (upper case) specifies a country or region
CurrentUICulture & CurrentCulture CurrentUICulture & CurrentCulture
CurrentUICulture—specifies the culture for the user interface and is used for resource file lookups.
CurrentCulture—specifies the culture for data and information. It is used to format dates, numbers, currencies and sort strings
how these settings work?how these settings work?
<%=System.Threading.Thread.CurrentThread. CurrentUICulture.ToString()%>
<%=System.Threading.Thread.CurrentThread. CurrentCulture.ToString()%>
What's New in APS.NET 2.0What's New in APS.NET 2.0
Auto Detection of Browser Language
Declarative Localization Expressions
Generating Local Resources
Culture-sensitive FormattingCulture-sensitive Formatting
Setting a Preferred Language in Internet Explorer
Auto-detecting the browser language for culture-sensitive formatting
<%@ Page Culture="auto:ar-SA" %>
LocalizationResource Expressions LocalizationResource Expressions
There are two forms of resource expressions, explicit and implicit:
Explicit
<%$ Resources:[filename prefix,]resource-key %>
Implicit
<asp:Label ID="Label1" runat="server" meta:resourcekey="resource-key-prefix" />
LocalizationExplicit Expressions to Local ResourcesLocalizationExplicit Expressions to Local Resources
Explicit localization expressions provide a way to declaratively assign specific resource entries to server control properties and other HTML elements
<asp:ImageButton id="btnIDesign" Runat="server" ImageUrl="~/Images/idesignlogo.jpg" AlternateText='<%$ Resources: MissionSatatement, "IDesign Inc." %>' PostBackUrl="http://www.idesign.net" meta:resourcekey="ImageButtonResource1" />
LocalizationExplicit Expressions to Local ResourcesLocalizationExplicit Expressions to Local Resources
Developers can create explicit expressions through the Properties window just as they would set other control properties
LocalizationImplicit Expressions to Local ResourcesLocalizationImplicit Expressions to Local Resources
The default behavior is for an implicit localization expression to be added to server controls, indicated by the parse-time attribute meta:resourcekey.
<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" runat="server" meta:resourcekey="LinkButtonResource1"> Change Culture Settings</asp:LinkButton>
LocalizationLocal and Global ResourcesLocalizationLocal and Global Resources
Global resources:Reside in a specialized folder called /App_GlobalResources
at the root of the application
Local resources:defined in a peer-level /App_LocalResources folder
LocalizationGenerating Local ResourcesLocalizationGenerating Local Resources
ASP.NET 2.0 provides a simple way to automatically generate resources for Web pages
Generate Local Resource from the Tools menu in Visual Studio 2005
Web Forms, user controls, and master pages can all be internationalized from within Visual Studio .NET 2.0. This particular view shows default resources generated for several pages.
LocalizationLocalizing HTML ElementsLocalizationLocalizing HTML Elements
HTML Controls cannot participate in the benefits of implicit or explicit expressions unless they are run on the server (runat="server").
In fact the HTML page title element is special because it is also a Page property that can be set through the @Page directive.
<%@ page title="Global Welcome" meta:resourcekey="pageTitle" %>
explicit expression that draws the value from shared resources instead
of local resources
<%@ page title='<%$ resource:Glossary, DefaultPageTitle, "Global Welcome" %>' %>
LocalizationDirectional AttributesLocalizationDirectional Attributes
To control the directionality of the browser's scrollbars and set the overall directionality of the site, this explicit expression pulls correct value from shared resources, and uses a designer default, "LTR":
<html runat="server" dir='<% $Resources: Direction, "LTR" %>' >
...
</html>
LocalizationStatic TextLocalizationStatic Text
A new ASP.NET Localize control is provided to mark static content as localizable
<asp:Localize runat="server" meta:resourcekey="welcome">Welcome!</asp:Localize>
<asp:Localize runat="server" text='<%$ resources: Glossary, welcomeText%>'>Welcome!</asp:Localize>
LocalizationResource Localization and DeploymentLocalizationResource Localization and Deployment
New declarative statements, automatic generation of page resources, and the presence of strongly-typed shared resources collectively make it much easier for developers to prepare Web applications for localization
LocalizationPreferred Culture SelectionLocalizationPreferred Culture Selection
ASP.NET 2.0 introduces a new feature to automate culture selection at runtime based on Web browser preferences. The @Page directive, which also supports culture and UI culture settings, can be used to indicate that a particular page should be run based on the browser preferences:
<%@ Page uiCulture="auto" culture="auto">
LocalizationPreferred Culture SelectionLocalizationPreferred Culture Selection
The web.config file for the application can also apply this setting for the entire application
<system.web> <globalization culture="auto:en-US" uiCulture="auto:en">
</system.web>
The colon after auto allows you to specify a default culture if the event HTTP headers are not available. Since culture must be set to a specific culture, the example above shows en-US as the culture.
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only.MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.