Download presentation
Presentation is loading. Please wait.
Published byMervyn Phelps Modified over 8 years ago
1
Localization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation
2
Key Terms (as used in this talk) Globalization (a.k.a. Internationalization) Core application handles international data Character encodings Date and time, numeric, currency formats … Market adaptation Additional functionality for a given market Localization = translation Localizable = ready for translation Resources Application elements (error messages, UI) to be translated in localized versions
3
.NET Framework Namespace System System.DataSystem.Xml System.Web Globalization Diagnostics Configuration Collections Resources Reflection Net IO Threading Text ServiceProcess Security Design ADO SQLTypes SQL XPath XSLT Runtime InteropServices Remoting Serialization ConfigurationSessionState CachingSecurity Services Description Discovery Protocols UI HtmlControls WebControls System.Drawing Imaging Drawing2D Text Printing System.WinForms DesignComponentModel
4
System.Resources namespace ResourceManager Provides access to culture-correct resources at runtime. ResourceWriter Writes resources to an output stream or file ResourceReader Reads resources name-value pairs from resources files and streams ResourceSet Stores all resources localized for a particular culture
5
System.Globalization.CultureInfo Provider of cultural preferences Two roles CurrentCulture Date and number formatting String comparison and casing CurrentUICulture Resource selection for user interface Can be controlled on a per thread basis RFC 1766 derived hierarchy CultureInfo.CreateSpecificCulture Optional mapping from neutral to specific
6
CultureInfo Neutral culture Based on language Resource only No formatting CurrentUICulture only Specific culture Based on language & region Resource & Formatting specifics CurrentCulture & CurrentUICulture
7
Resource Model .NET Framework uses a new resource model ResX file format Resources files Satellite Resources DLLs Naming conventions Resource Fallback
8
ResX Files Simple, (almost) human-readable XML format Can include arbitrary objects Created with.NET Framework SDK Can also be created with Visual Studio See other talk on this topic
9
Resource generation process .resx file XML-based file Describes resources .resources file binary compiled file Satellite.resources.dll: Embedded.resources file(s).resx file.resources file.resources.dll file
10
Naming convention Naming pattern conventions.resources files: ..resources Satellite assemblies .resources.dll Directory locations for satellites: A subdirectory per culture either neutral or specific cultures can be used Myproject.dll \fr\myproject.resources.dll(neutral) \de-DE\myproject.resources.dll(specific)
11
Resource Fallback
12
Loading Resources Creating a Resource Manager The RM constructor indicates the file from which resources are to be loaded. Several alternatives Load from a loose.resources file Load from this assembly Load from another assembly Load from a custom resource format if you write your own resource manager (e.g. a database) See.NET SDK, Samples and Tutorials, ASP.NET QuickStarts, and How Do I … samples
13
Loading Resources, continued Resource manager can be used to load both strings and objects: RM.GetString (“mystring”, new CultureInfo(“en-NZ”) ) RM.GetString (“mystring”) RM.GetObject(“Button1.Cursor”) Loads requested resources based on Thread.CurrentThread.CurrentUICulture Fallback hierarchy derived from RFC 1766
14
Localization Process Start with a.txt or a.resx file.txt files(string data only).resx files(string data and arbitrary objects) XML tools can be used with.resx files External localization tools vendor support Lionbridge, http://www.lionbridge.comhttp://www.lionbridge.com WinRes Resize WindowsForms forms WinRes does not require access to source Visual Studio IDE: integrates this capability ResGen: Compile data to.resources binary files
15
Localization Process AL (or compiler): add.resources into assembly. (AL is an SDK linker) al /t:lib /culture:en-NZ /embed:strings.en- NZ.resources /out:myapp.resources.dll Optional: use SN for strong-naming VS IDE : add translated.resx file into project
16
ASP.NET And Localization ASP.NET has a flexible resource model There is not one single way to organize localizable resources Applications vary; developers can choose. The following section shows a few alternatives..NET Framework SDK has additional samples ASP.NET QuickStarts, localization section, working with resources files.
17
ASP.NET Localization Options A: Resources included in source (like ASP) Copy of each page per language Specify culture in page directive or web.config Advantages: Good for static content Rapid initial development Disadvantages: High maintenance costs Not suitable for dynamic content Localizers and developers are working on the same source file. Potential for conflicting updates Not recommended
18
ASP.NET Localization Options B: Resources separated from source Use Resource Manager to load resources Resources could be in Loose.resources files Satellites below each main assembly A separate (parallel) main assembly with satellites below it One.resources file or satellite per language Slightly different ResourceManager constructors for each case
19
ASP.NET Localization Options B: Resources separate from source, continued: Advantages: Can deploy additional languages incrementally, without redeploying core code Lower maintenance costs, as there is one central app, not many parallel versions. Disadvantages: More files Loose.resources can have locking issue. No locking issue for satellites or parallel main assembly with satellites. Shadow-copying done for exes and dlls (main assemblies and satellites). Samples: ASP.NET Quickstarts, Localization section
20
ASP.NET Localization Options C: Satellite Resource DLLs Advantages: Can deploy additional languages incrementally, without redeploying core code Lower maintenance costs, as there is one central app, not many parallel versions. Shadow-copying done for exes and dlls (main assemblies and satellites). Disadvantages: More files Added initial application development complexity
21
Demo Localizing a WebForm application
22
Summary .NET Framework provides built-in support for localization and globalization ASP.NET builds on Framework support for international app development More options for specifying encoding Can separate code from resources Can utilize.NET Frameworks classes Developers can develop/host multi-cultural apps on a single server Visual Studio makes it easier to build localized apps See Achim Ruopp’s talk
23
Additional References .NET Framework SDK Tutorial: Resources and localization (includes tools) .NET Framework SDK Samples ASP.NET Quickstart Localization section WinForms QuickstartLocalization sample How Do I … samples: Resources Globalization .NET Framework SDK Tools: ResGen, WinRes, AL, SN
24
Additional References Documentation.NET Framework SDK: Developing World-Ready Applications Visual Studio : Visual Studio.NET\Visual Basic and VisualC#\Globalizing and Localizing\Walkthroughs General info on.NET Framework: http://msdn.microsoft.com/net http://www.GotDotNet.com
25
Questions ?
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.