是否有在的WinForms本地化常见的文本存储库?文本、常见、WinForms

2023-09-02 10:33:41 作者:夜凉初透陌汐

我在全球化的Windows窗体应用程序。

I'm globalizing a Windows form application.

有没有一种方法来访问常用文字在当前语言的Windows?

Is there a way to access common text in the current language for Windows?

例如,对于确定的标签,取消和接受按钮;如果我构建了一个OK按钮的一种形式,我想使用Windows所用其他地方的OK按钮相同的转换。

For example, for the labels of OK, Cancel and Accept buttons; if I'm building a form that has an OK button I would like to use the same translation that Windows uses everywhere else for OK buttons.

我知道我可以存储翻译为他们自己,但Windows有有他们的地方存放,做他们给开发人员可以访问它们?

I know I can store the translation for them myself, but Windows has to have them stored somewhere, do they give developers access to them?

推荐答案

是的,理论上可以提取从Windows的内部系统文件的本地化字符串。但不这样做。其优点是由可能的缺点远远超过。您的应用程序不应该依赖于无证执行细节。没有理由,试图从Windows获得此。

Yes, theoretically you could extract localized strings from Windows's internal system files. But don't do it. The advantages are far outweighed by the possible disadvantages. Your application shouldn't be reliant on undocumented implementation details. There's no reason to try and get this from Windows.

这也是值得指出的是,你可以重命名的按钮(和所有其他的控制)。这意味着它太容易碰坏,如果你依赖于某种形式的字符串匹配算法。有没有办法来标记按钮作为某种类型,这样它会自动与特定标题有关的,即使你的可以的,这不会涵盖所有按钮present在一个非平凡的UI。此外,由于乔伊的回答指出,有比一的部分的本地化的UI用户更糟糕。一致性是关键,你不能本地化标签,组合框,菜单,工具提示,等等这样的。

It's also worth pointing out that you can rename buttons (and every other control). That means it's too easy to break something if you're relying on some kind of string matching algorithm. There's no way to mark a button as being a certain "type" so that it will be automatically associated with a particular caption, and even if you could, this wouldn't cover every button present in a non-trivial UI. Also, as Joey's answer points out, there's nothing worse for the user than a partially localized UI. Consistency is the key, and you can't localize labels, group boxes, menus, tooltips, etc. this way.

请注意,但是,该Windows的将会的自动对一个消息框本地化的字幕按钮(的 的MessageBox )。你不必动一根手指。

Note, however, that Windows will automatically localize the captions for buttons on a message box (MessageBox). You don't have to lift a finger.

什么是错的形式的本地化属性设置为True(必须在设计时做到这一点)和所有的的提供本地化的文本在应用程序的控制? Windows窗体实际上有本地化pretty的COM prehensive支持;设计者将自动序列化所有本地化的元素到窗体的RESX文件。请参阅MSDN:演练:本地化的Windows窗体。请确保你离开的空间足够量,以便对前pressions不同语言的不同长度。

What's wrong with setting the form's Localizable property to True (you must do this at design time) and providing localized text for all of the controls in your application? Windows Forms actually has pretty comprehensive support for localization; the designer will automatically serialize all localizable elements to the form's RESX file. See MSDN: Walkthrough: Localizing Windows Forms. Make sure that you leave a sufficient amount of space to allow for the varying lengths of expressions in different languages.