Search code examples
c#buttonribbon

Localize the text in ribbon buttons


I have a ribbon window with a number of buttons wich is using a resources like this

<r:RibbonWindow.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <r:RibbonCommand x:Key="CopyCommand"  
                         LabelTitle="Copy"  
                         ToolTipDescription="Copy something"  
                         Executed="OnIgnore"  
                         LargeImageSource="images/Flag/de-DE.png"
                         SmallImageSource="images/Flag/en-GB.png"
        />
    </ResourceDictionary>
</r:RibbonWindow.Resources>


<DockPanel>
    <r:Ribbon DockPanel.Dock="Top" Title="EasyLink">
            <r:RibbonTab Label="Home">
                <r:RibbonGroup Name="Clipboard"  GroupSizeDefinitions="{StaticResource RibbonLayout}">
                    <r:RibbonButton Name="Copy"  Command="{StaticResource CopyCommand}" />
            </r:RibbonGroup>
        </r:RibbonTab>
        <r:RibbonTab Label="Help">
        </r:RibbonTab>
    </r:Ribbon>
</DockPanel>

I want to use the "strings" concept to have the buttons change text depending on the language.

I have tried the following

        <r:RibbonCommand x:Key="CopyCommand"  
                         LabelTitle="me:strings.Copy"  

and

        <r:RibbonCommand x:Key="CopyCommand"  
                         LabelTitle="/Test;strings.Copy"

but it did not work, should I do it elsewhere, in the C# code perhaps ?


Solution

  • I found the answear here http://gargmanoj.wordpress.com/2009/03/18/accessing-strings-from-resource-file-in-xaml-markup/

    It is needed to make the string resources Public and refer to them as static

    Regards