#1,126 – Localization VII – Preventing Translator from Modifying Certain Elements

By default, when a .csv file is created using the LocBaml tool, the fifth parameter on each line is set to True.  This parameter indicates whether a particular property should be modifiable by the translator.

You can change the value of this modifiable field by setting the Localization.Attributes property for an element.  This property is set to a string of the form “propname(locvalue1 locvalue2) propname(locvalue1 locvalue2)”.

One of the localizability values that you can set is Unmodifiable, to indicate that the specified property should not be modified by the translator.

Below, we set Unmodifiable for various property values.

<Window x:Uid="Window_1" x:Class="WpfApplication1.MainWindow"
        Localization.Attributes="$Content(Unmodifiable) SizeToContent(Unmodifiable)"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="The App" SizeToContent="WidthAndHeight">

    <StackPanel x:Uid="StackPanel_1" Margin="15"
                Localization.Attributes="Margin(Unmodifiable)">
        <Label x:Uid="Label_1" Content="Hello, I like apples."
               Localization.Attributes="$Content(Unmodifiable)"/>
        <Button x:Uid="Button_1" Content="Learn More" Margin="5"
                Click="Button_Click"
                Localization.Attributes="$Content(Unmodifiable) Margin(Unmodifiable)"/>
    </StackPanel>
</Window>

After running the LocBaml tool, we see that the modifiable field is now false for these properties.

1126-001

Advertisements