I have followed the instructions in "Localize an Application", and have as an example a csv-file with 14903 elements, where I guess about 100 is supposed to be translated. The rest is Gradients, Pens, etc, etc. Here is an example of one of the many source files, and its LocBaml output:
<ResourceDictionary x:Uid="ResourceDictionary_1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <LinearGradientBrush x:Uid="LinearGradientBrush_1" x:Key="WindowBorder" StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop x:Uid="GradientStop_1" Offset="0" Color="#5050A2" /> <GradientStop x:Uid="GradientStop_2" Offset="1" Color="#5050A2" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> ...
</ResourceDictionary>
These lines are split so they're not too long...
Mango.UI.g.en-US.resources:vectorgraphics.baml,LinearGradientBrush_1:
System.Windows.Media.LinearGradientBrush.$Content,None,False,True,, Mango.UI.g.en-US.resources:vectorgraphics.baml,LinearGradientBrush_1:
System.Windows.Media.LinearGradientBrush.StartPoint,None,True,False,,"0,0" Mango.UI.g.en-US.resources:vectorgraphics.baml,LinearGradientBrush_1:
System.Windows.Media.LinearGradientBrush.EndPoint,None,True,False,,"0,1" Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_1:
System.Windows.Media.GradientStop.$Content,None,False,True,, Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_1:
System.Windows.Media.GradientStop.Offset,None,False,True,,0 Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_1:
System.Windows.Media.GradientStop.Color,None,False,True,,\#5050A2 Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_2:
System.Windows.Media.GradientStop.$Content,None,False,True,, Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_2:
System.Windows.Media.GradientStop.Offset,None,False,True,,1 Mango.UI.g.en-US.resources:vectorgraphics.baml,GradientStop_2:
System.Windows.Media.GradientStop.Color,None,False,True,,\#5050A2
Notice that none of these elements is something we want to translate. But to get LocBaml to to expose these, I have to modify the XAML so that it becomes totally unreadable. And we have lots of styles, control templates etc that will show up in the LocBaml output. This is how I did it:
<LinearGradientBrush Localization.Attributes="$Content (Unreadable Unmodifiable NeverLocalize) StartPoint (Unreadable Unmodifiable NeverLocalize) EndPoint (Unreadable Unmodifiable NeverLocalize)" x:Uid="LinearGradientBrush_1" x:Key="WindowBorder" StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Localization.Attributes="$Content (Unreadable Unmodifiable NeverLocalize) Offset (Unreadable Unmodifiable NeverLocalize) Color (Unreadable Unmodifiable NeverLocalize)" x:Uid="GradientStop_1" Offset="0" Color="#5050A2" /> <GradientStop Localization.Attributes="$Content (Unreadable Unmodifiable NeverLocalize) Offset (Unreadable Unmodifiable NeverLocalize) Color (Unreadable Unmodifiable NeverLocalize)" x:Uid="GradientStop_2" Offset="1" Color="#5050A2" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush>
What is the story here Will we have to spend two man-weeks on adding Localization.Attributes to all element that we don't want to translate Or will there exists some OK defaults that we can apply or...
/Andreas

How is localization supposed to work in a big XAML application?
NiekL
It is a free tool and I intend to keep it free, containing all current features. A small charge may be applied for some features I may introduce later, just to help me keep supporting and enhancing the project.
I encourage you to download ResEx and post any suggestions to the discussions page you can find under Help menu of the application. Info and download
Here is a list of features provided by ResEx:22
- Translate values side by side (just like the old time classic VB6 resource editor)
- Lock specific strings so that translator does not translate them
- Ensure correct translation of strings with placeholders {0} {1} ...
- View resource strings in tree form
- Translate resources without Visual Studio IDE
- Search inside resource files while translating
Regardsyoga80
Hi, Andreas.
There are actually 3 localizability attributes that can help people to filter the values. In terms of LocBaml’s output, they are:
Third Column - Category. It is hint of what type the value is. For well-known UI values, there are categories like "Text", "Button", "ComboBox", etc. For non-UI/undetermined types, it is “None”. A project may only localize some of these categories. In your project, an option is use localization comments to set all the localizable values (seems not many of them) to a certain category and only localize that category later.
Fourth Column – Readability. We’ve talked about that above. It is a hint whether a value is a readable string. For example, RGB values is not “readable”, but a TextBlock’s value is. In your localization, you can filter out “unreadable” values.
Fifth Column – Modifiability. It tells whether a value can be modified by localizer. This setting can be customized by the project and the developers. In LocBaml, most of the numerical values are not modifiable by default (e.g. StartPoint, EndPoint).
In general, one needs to filter by all three columns to find the best set of localizable values. WPF already comes with a decent set of localizability attributes for its types. But it may not fit all. You can customize all of these attributes through the localization API. I think this information is already mentioned in the WindowsSDK web-site.
After all, LocBaml is a SDK sample whose primary goal is to let people learn about the localization API, localizability attributes and work-flows. It brainlessly dumps all stuff out. I totally agree that there is room for refinement and thanks for the feedbacks! I think it should be relatively easy for you to adapt it to do what you want.
Slimer74
Wow, can you please make sure that this information gets into the documentation Because this is exactly the information/specification I was looking for.
Even though LocBaml is a sample, I assume that exisiting translation tools will use the 'x:Uid' attributes and the localization comments I ask this because we would probably want to start to tag everything now, so that we're ready when the localization phase starts.
Oh, and make sure that the documentation on Localizable.Attributes gets updated. For example, Readable/Unreadable and its friends are not specified anywhere, but rather implied throughout the text.
mAh3u
Hi, Andreas,
In the LocBaml output, the 4th column is a boolean value for "readability". For all the Brush, GradientStop, and such, the values in this column will be "false" by default. It means that those values should not be directly translated. But they can still be changed if a localizer wishes to do so. LocBaml would not hide an entry as long as it is potentially localizable.
In your case, you can just sort the CSV by the 4th column and delete all the "unreadable" entries, save the result to a new CSV. You can then use that CSV for localization. Will this work for you
Thanks.
duck16
Well, no (or rather a very reluctant yes).
First, to be able to open the files in Excel, I first have to open them in csvUni and convert them to ;-separated. You (as in american developers) do know that Excel treats csv as a locale dependent file format I'm running under Swedish locale, which doesn't have , as list-separator.
Secondly, when I do manage to open the files in Excel and filter on the fourth column, I still have some very weird values that apparently is "very important to translators". As an example: Storyboard.TargetName and TargetProperty. And from our previous example, LinearGradientBrush.StartPoint and EndPoint. And more and more and more. It seems that someone was somewhat optimistic in their view that a translator should be interested in the Path for a Data.Binding for example.
So we will have to go through the list manually everytime we regenerate, but it will at least be a shorter list.
In our first tests this will have to do, but it would be nice to be able to: