本地化按钮文字 [英] Localize button text

查看:66
本文介绍了本地化按钮文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个项目,(C#,wpf,.net 3)并使用字符串.本地化的概念
我的应用程序使用不同的语言.

如何将按钮文本设置为正确的语言?

它不适用于
myButton.SetText(strings.hello)

是在xml文件中为窗口执行操作,还是可以/应该在C#代码中执行操作?


问候

Hi
I have a project, (C#, wpf, .net 3) and uses the strings. concept to localize
my application for different languages.

How do I set the button text to the correct language ?

It does not work with
myButton.SetText(strings.hello)

Do I do it in the xml file to for the window or can/should I do in the C# code ?


Regards

推荐答案

在项目的属性中添加不同语言的资源文件,并根据语言代码对它们进行命名,例如巴西葡萄牙语(将资源文件命名为StringResource之类的名称.pt-BR.resx).现在,在Button控件的text属性中编写类似于myButton.Content = Properties.StringResource.IDOfTheString的内容.根据Syatem语言,它将非常小心.检查< a href ="http://www.codeproject.com/KB/dotnet/Localization.aspx"/>以获得关于本地化问题的更多想法.
In Properties of your project add Resource files for different languages and name them according to the Language code like for Brazilian-Portuguse(name your resource file something like StringResource.pt-BR.resx). Now in text property of the Button control write something like myButton.Content= Properties.StringResource.IDOfTheString. According to the Syatem Language it will take care. Check <a href="http://www.codeproject.com/KB/dotnet/Localization.aspx"/> for getting more idea on Localization Issues.


Bizarre.第一个 Google匹配 [
Bizarre. The first google hit[^] was an article on this very site. I know some countries don''t have google, but you obviously have code project. You didn''t think to search the site for articles ?


为什么不将要在按钮中显示的文本保存到资源文件中,而程序却在,确定默认语言(这是另一门语言),然后选择正确的资源文件.
Why don''t you save the text what you want to show in button into a resource file, and while the program star, identify which language is default(this is another subject), then select the right resource file.


这篇关于本地化按钮文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆