Using Localization.Comments on strings defined in a ResourceDictionary

245 Views Asked by At

We use the LocBaml tool to localize our application. For that, we have created a ResourceDictionary as described in this post: https://wpf.2000things.com/2014/08/12/1134-localization-xv-localizing-other-content/

Instead of using Controls like Button or FrameworkElements like TextBlock, we directly use System.String as follows, which works fine so far:

<ResourceDictionary x:Uid="ResourceDictionary_1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib">
  <System:String x:Uid="System:String_1" x:Key="Home">Home</System:String>
 </ResourceDictionary>

But if we try to use the Localization.Comments attached property (for LocBaml as input; it generates an additional column in the output and fills in the comment, which we want to use to give some hints to our translation personnel), the compiler complains that this is not supported. We suspect that this only works on FrameworkElements, maybe also on DependencyObjects.

Is there any way to make this work on our raw strings (maybe by defining the AttachedProperty for string, too; or writing an extension method)? We want to be able to use these in different controls like MessageBox and Button, and in FrameworkElements like TextBlock. So adding these to the resources instead is not an option for us.

P.S.: Why are x:Key and x:Uid working on these raw strings then? Maybe we can extend this via the same mechanism to Localization.Comments?

0

There are 0 best solutions below