Best Practices for Globalization and Localization in WPF
You can make the most of the globalization and localization functionality that is built into Windows Presentation Foundation by following the UI design and localization-related tips that this section provides.
Best Practices for WPF UI Design
When you design a Windows Presentation Foundation–based UI, consider implementing these best practices:
Write your UI in XAML; avoid creating UI in code. When you create your UI by using XAML, you expose it through built-in localization APIs.
Avoid using absolute positions and fixed sizes to lay out content; instead, use relative or automatic sizing.
Use SizeToContent; and keep widths and heights set to
Auto
.Avoid using Canvas to lay out UIs.
Use Grid and its size-sharing feature.
Provide extra space in margins because localized text often requires more space. Extra space allows for possible overhanging characters.
Enable TextWrapping on TextBlock to avoid clipping.
Set the xml:lang attribute. This attribute describes the culture of a specific element and its child elements. The value of this property changes the behavior of several features in WPF. For example, it changes the behavior of hyphenation, spell checking, number substitution, complex script shaping, and font fallback.
Create a customized composite font to obtain better control of fonts that are used for different languages. By default, Windows Presentation Foundation uses the GlobalUserInterface.composite font in your Windows\Fonts directory.
When you create navigation applications that may be localized in a culture that presents text in a right-to-left format, explicitly set the FlowDirection of every page to ensure the page does not inherit FlowDirection from the NavigationWindow.
When you create stand-alone navigation applications that are hosted outside a browser, set the StartupURI for your initial application to a NavigationWindow instead of to a page (for example,
<Application StartupUri="NavigationWindow.xaml">
). This design enables you to change the FlowDirection of the Window and the navigation bar.
Best Practices for WPF Localization
When you localize WPF applications, consider implementing these best practices:
Use localization comments to provide extra context for localizers.
Use localization attributes to control localization instead of selectively omitting Uid properties on elements.
Use msbuild /t:updateuid and /t:checkuid to add and check Uid properties in your XAML. Use Uid properties to track changes between development and localization. Uid properties help you localize new development changes. If you manually add Uid properties to a UI, the task is typically tedious and less accurate.
Do not edit or change Uid properties after you begin localization.
- Do not use duplicate Uid properties (remember this tip when you use the copy-and-paste command).
- Set the
UltimateResourceFallback
location in AssemblyInfo.* to specify the appropriate language for fallback (for example,[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
). - If you decide to include to include your source language in the main assembly by omitting the <UICulture> tag in your project file, set the UltimateResourceFallback location as the main assembly instead of the satellite (for example, [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]).
About Us
We are the Windows Presentation Foundation SDK writers and editors.
Comments
Anonymous
July 07, 2006
Pour ceux qui ne l'aurait pas remarqué, l'équipe en charge de SDK (Software Development Kit) de WPF (Windows...Anonymous
August 01, 2006
We (the US ISV Evangelism Team) hosted a successful ISV CTO Summit last month for 150 managed partners, achieving an 8 out of 9 event rating. Our goals were to convey product info on emerging Microsoft technologies, provide strategy/roadmap insight viaAnonymous
August 20, 2006
You can make the most of the globalization and localization functionality that is built into Windows...Anonymous
October 07, 2006
PingBack from http://windowspresentation.wordpress.com/2006/10/08/best-practices-for-globalization-and-localization-in-windows-presentation-foundation/Anonymous
October 30, 2007
Many of my customers asked me: How WPF supports localization and globalization? Is there any built-inAnonymous
April 23, 2008
My team has been looking how to make localization support in WPF better.  We hope to improve thingsAnonymous
March 11, 2009
Olá a todos, Gostaria de aproveitar no primeiro post deste blog, para não só desejarAnonymous
May 11, 2009
Several techniques exist for localizing WPF applications. I have yet to study them before making a choiceAnonymous
May 16, 2009
We use an alternative approach with the old stable "ResX" files to localize a WPF application. This technique is better supported by Visual Studio 2008. Furthermore, you can use the same approach for WinForms as well. See also: Best Practices: How to localize a WPF application (with ResX files) http://compositeextensions.codeplex.com/Thread/View.aspx?ThreadId=52910 jbe