Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Globalize and Localize Your "Avalon" Applications Using LocBaml : Page 3

You already know that internationalizing your applications can propel you into new markets. But did you know that the Windows Presentation Framework can make it easier than ever to do? Learn how to write culture-aware WPF applications using this example.

Specifying a Language
In the project file of the current project, you need to specify the current default culture used so that when the project is built, a main assembly and a satellite assembly (for the default language) will be built.

In WPF.vbproj, add the following line in bold:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/ developer/msbuild/2003"> <PropertyGroup> <UICulture>en-US</UICulture> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> ...

This specifies that the default culture used for this application is "en-US". You can now compile the application using Build->Rebuild WPF (see Figure 7).

Figure 7. Compile: Rebuild the WPF project.
Figure 8. Saving the Resources: The satellite assembly for the en-US culture is shown.

A WPF.resources.dll file containing all the resources used by your application will now be located in the "C:\WPF\bin\en-US" folder (see Figure 8).

Building the LocBaml Tool
Once the resources used by the application are extracted as a resource file (.resource.dll), you can easily create another resource file containing the elements of the language you are targeting (Chinese, in this example). For this task, you will make use of a tool provided by Microsoft—LocBaml (Localize Binary Application Markup Language). You can download the LocBaml tool from: http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcp_samples/html/ef1f62b2-3ab7-4fe1-9494-4bf58fadfb57.asp. The LocBaml tool is used to parse resources files and extract text elements so that they can be localized easily.

As only the source code of the tool is provided, you need to do some work in order to use the tool. Assuming that the source code of the LocBaml tool is saved in the C:\LocBaml directory, the CSharp folder contains the actual source code of the LocBaml tool and the XAML folder contains a sample application for you to test the tool (we won't be using it for this article).

In Start->Programs->Microsoft WinFX SDK->Release Build Environment, change to the directory containing the LocBaml tool project file and type (see also Figure 9):

C:\LocBaml\CSharp>msbuild LocBaml.csproj

Figure 9. BAM!: Use the command shown to build the LocBaml tool.
Figure 10. Finding the EXE: The location of the executable of the LocBaml tool is shown.

The executable part (.exe) of the tool will now be located in C:\LocBaml\CSharp\bin\Debug (see Figure 10).

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date