This project is read-only.
Project Description
The objective is to extract strings from xaml file and generate resx file. The tool is integrated in Visual Studio.

Add ins for Visual Studio 2008 SP1 / Visual Studio 2010 Beta 2 (support C#, VB.Net, other ?)


In your XAML file, you have a lot control with text to localize, but in the actual version, Visual Studio do not export string to resx file (like Windows Forms/

For example :
<dataInput:Label Name="label1" Content="Epargne mensuelle" />

If you want to localize this (for WPF, there is another method), you need to create a .resx file and then create a binding, thus for example :
<dataInput:Label Name="label1" Content="{Binding label1_Content, Source={StaticResource Epargneres}}" /> (and other plumbing to create Epargneres).

This tools does the work for you, it parses the XAML file, create the resx file and adapt the XAML file.
The process can be incremental, if you add new strings, you relaunch the tools, it adds the new strings in resx and adapt XAML file.

How (by binding)

You install the add-ins in visual studio (close VS and launch the setup).
Open your solution (make a backup before testing for the first time), select one or more XAML file in solution explorer, go to the menu Tools, and choose Generate XAML Resource.
The tools creates a new Directory App_Resource (if it does not exist) and a .resx file, if you have a correct Custom Tool Resx Generator, the .designer is created too.
The tools modify the XAML file.

If you select a project, the tools scan all XAML file in the project.

Other method (by code)

I implement the method with binding because this method is described in many blog. But for my use :
- the xaml file is less readable ;)
- the public resx class is useless for programmation and need another tools.
because of that, i create another approach.

The resx files are still generated, but the XAML is not modified, i create a new file ....xaml.translat.cs/vb with lines like
this.label1.Content = ResourceManager.GetString("label1_Content");
Do not forget to modify the code of xaml.cs/vb to call Translate after InitializeComponent in the constructor.

External Dependencies


The tools need a unique identifier, then it chooses x:Uid if present, if not it use Name or x:Name.
If you element has no Uid and no Name, nothing happens.

You can use the option to create Name automatically, but this adds member field for each element, and do not work for template.
You can use the option to create Uid too.

For the method by code, only control with a Name are localized (<telerikNavigation:RadMenuItem Header="Plan Financier" /> is not extracted but (<telerikNavigation:RadMenuItem Name="MenuPlanFin" Header="Plan Financier" /> is good).

Last edited Dec 28, 2009 at 1:40 AM by Cestbienmoi, version 9