WPF 中的本地化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/795025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:18:19  来源:igfitidea点击:

Localization in WPF

wpflocalizationresx

提问by Lukasz

I am starting a new application in WPF and I am curious how to handle Localization? In WinForms you can use resx strings for the UI text, how is this done in WPF? Is there a special binding syntax for binding to resx resources or is there a different way of doing this?

我正在 WPF 中启动一个新应用程序,我很好奇如何处理本地化?在 WinForms 中,您可以对 UI 文本使用 resx 字符串,这是如何在 WPF 中完成的?是否有用于绑定到 resx 资源的特殊绑定语法,或者是否有不同的方法来执行此操作?

Thanks!

谢谢!

采纳答案by Madeleine

Check out WPF Globalization and Localization Overview. The article explains nicely how localization in WPF works.

查看WPF 全球化和本地化概述。这篇文章很好地解释了 WPF 中的本地化是如何工作的。

回答by Madeleine

you can use a MarkupExtensionto do localization with dynamic language switching. Here is an interesting article about this:

您可以使用MarkupExtension通过动态语言切换进行本地化。这是一篇关于此的有趣文章:

http://www.wpftutorial.net/LocalizeMarkupExtension.html

http://www.wpftutorial.net/LocalizeMarkupExtension.html

回答by Marny Jeckel

I found very easy to start WPF localization with VS template, described in authors blog.

我发现使用 VS 模板很容易启动 WPF 本地化,如作者博客中所述

Project created using this template already contains all the necessary tools for localization, as well as the maximum automates the localization process. During application development, you add a new XAML file without having to worry about localization. Upon completion of the changes simply build project and change default language to translated.

使用此模板创建的项目已包含本地化所需的所有工具,并且最大限度地自动化了本地化过程。在应用程序开发期间,您可以添加新的 XAML 文件而不必担心本地化。完成更改后,只需构建项目并将默认语言更改为翻译。

Downloadtemplate

下载模板