最佳实践,使在C#/的WinForms一个多语言的应用? [英] Best practice to make a multi language application in C#/WinForms?

查看:128
本文介绍了最佳实践,使在C#/的WinForms一个多语言的应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找到,因为我需要在一个小的项目中,这种情况下工作,使其适用于C#多语言的应用程序。我发现基本上有两种方法可以做到这一点:

I've been looking into making applications suitable for multiple languages in C# since I need to work on a small project where this is the case. I have found basically two ways to do this:

设置窗体的本地化属性设置为true,设置语言属性,填写所有的标签,这样,和你'做'。主要的缺点我在这看到的是:如何让其他的东西,这是不是准备好多种语言(例如弹出窗口,日志文件或窗口等)

Set a form's Localizable property to true, set the Language property, fill all the labels and such, and you're 'done'. The major drawback I see in this is: how to make other stuff which is not part of a form ready for multiple languages (e.g. pop-up windows, log files or windows, etc).

创建一个资源文件,例如Lang.en-us.resx',一个用于每一种语言,例如Lang.nl-nl.resx和字符串填满它。该IDE似乎自动生成的类对我来说,所以在code我可以只使用Lang.SomeText。我在这看到的最大的缺点是:为每一个形式,我需要设置所有的标签和其他字幕自己在code(和它似乎并没有数据与这些资源结合作品)

Create a resource file, for example 'Lang.en-us.resx' and one for every language, for example 'Lang.nl-nl.resx' and fill it up with Strings. The IDE seems to generate a class for me automatically, so in the code I can just use Lang.SomeText. The biggest drawback I see in this is: for every form I need to set all the labels and other captions myself in the code (and it doesn't seem data binding works with these resources).

我敢肯定,但是,还有其他的方法来做到这一点。

I'm sure, however, that there are other methods to do this as well.

那么,什么是最好的做法?什么是最简单的小应用程序(一些表格,数据库连接等),什么尺度最适合较大的应用程序?

So, what is the best practice? What's the easiest for small applications (a few forms, database connection etc) and what scales best for larger applications?

推荐答案

我一直使用多语言应用程序的资源文件。结果
该是网络解释如何使用他们的文章。结果
结果
我用两种不同的方式:

I have always used resource files for multi-language applications.
The are many articles on the web explaining how to use them.

I have used two different ways:


  • 每个表单的资源文件

  • 全局资源文件

资源文件/表格,更容易实现,只需要在资源文件中输入的值,但我觉得这种方式难以维持,因为标签是分散在整个应用程序。

The resource file / form, is easier to implement, you only need to enter the values in the resource file, but I find this approach harder to maintain, since the labels are dispersed throughout the application.

全局资源文件,您可以在(每个语言)一个文件集中所有的标签(图片等),但它意味着在窗体加载手动设置标签。该文件还可以用于对错误消息等。

The global resource file allows you to centralise all the labels (images etc.) in one file (per language), but it means manually setting the labels in the form load. This file can also be used for error messages etc.

品味的问题...

最后一点,我写在英语和法语节目,我用恩和FR,而不是EN-US和FR-FR。不要复杂的事情,英语(美国,英国,澳大利亚等)的不同dilelects很少有足够的差异只有一个使用(同样也适用于法国)。

One last point, I write programs in English and French, I use "en" and "fr" and not "en-US" and "fr-FR". Do not complicate things, the different dilelects of English (American, English, Australian etc) have few enough differences to use only one (the same goes for French).

这篇关于最佳实践,使在C#/的WinForms一个多语言的应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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