In my last post I talked about using resource files (resx) to localize your WPF application. This time it is about using LocBaml to localize your WPF application. The big difference in the two approaches is that LocBaml allows you to localize your application after the fact. That is, most applications you have to plan up front to do localization, but with LocBaml you can still localize your application after development. While lots of people will say this I don't really believe it. The reason this is not true in my opinion is because LocBaml only works if all your strings are sourced in XAML. This means that if you use strings that are located in a constant file or a resx file LocBaml will not work to localize your application. Unless you are building a smaller application or you just happen to set up your architecture so all strings are sourced in XAML you are out of luck. So really when they say you can localize your application after the fact you really can only do it if you happened to conform your application to the requirements of LocBaml. On that note lets get into preparing the application with UIDs.
In my previous example I had three labels in my application. The first label had its text defined in XAML. The other two used resx files to define their text. In this walk through we will update the first label so we can localize it as well. The first thing we want to take note of is the current XAML layout of our label.
<Label Height="28" Margin="10,13,33,0" Name="lblFromXAML" Content="Text from XAML" VerticalAlignment="Top"></Label>
Now if you look at the XAML that makes up the label you will see the addition of UID attribute.
<Label x:Uid="lblFromXAML" Height="28" Margin="10,13,33,0" Name="lblFromXAML" Content="Text from XAML" VerticalAlignment="Top"></Label>
If you could not tell there are a lot of hoops to get through doing localization this way. Personal, I think the process is pretty ridiculous. I have no idea why someone would do localization this way instead of using resx files. I see only cons to this approach and no advantages over the resx approach. If you have a different opinion I would really like to hear your thoughts.
Comments