本地化功能区按钮中的文本

发布于 2024-11-28 09:59:31 字数 1636 浏览 4 评论 0原文

我有一个带有许多按钮的功能区窗口,它们正在使用这样的资源,

<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>

我想使用“字符串”概念让按钮根据语言更改文本。

我已尝试以下操作

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

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

但它不起作用,我应该在其他地方(也许是在 C# 代码中)执行此操作吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮邮递员 2024-12-05 09:59:31

我发现 WPF 中 UI 元素声明式本地化的最佳且最简单的解决方案是 WPF 本地化扩展 (http://wpflocalizeextension.codeplex.com/)。它提供了额外的表达,例如:

"Text = {lex:LocText ResAssembly:ResFile:ResKey}"

额外的好处是,当当前用户无法使用本地化时,它支持回退机制。

我个人将它与 Ribbon 一起使用,非常顺利。

The best and easiest solution to declarative localization of UI elements in WPF that I found is the WPF Localization Extension (http://wpflocalizeextension.codeplex.com/). It provides additional expression, for example:

"Text = {lex:LocText ResAssembly:ResFile:ResKey}"

The additional benefits are that it supports fall-back mechanism when localization is not available for current user.

I personally used it with Ribbon and it went quite smooth.

骄兵必败 2024-12-05 09:59:31

我在这里找到了答案
http://gargmanoj。 wordpress.com/2009/03/18/accessing-strings-from-resource-file-in-xaml-markup/

需要将字符串资源公开并将它们称为静态

问候

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文