WinForms 中是否有本地化常用文本的存储库?

Is there a repository for localized common text in WinForms?(WinForms 中是否有本地化常用文本的存储库?)

本文介绍了WinForms 中是否有本地化常用文本的存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在全球化一个 Windows 表单应用程序.

I'm globalizing a Windows form application.

有没有办法以 Windows 的当前语言访问常用文本?

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

例如对于OK、Cancel和Accept按钮的标签;如果我正在构建一个带有 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.

还值得指出的是,您可以重命名按钮(以及所有其他控件).这意味着如果您依赖某种字符串匹配算法,那么很容易破坏某些东西.没有办法将按钮标记为某种类型",以便它自动与特定标题关联,即使您可以,这也不会涵盖非-琐碎的用户界面.此外,正如 Joey 的回答所指出的,对于用户而言,没有什么比 部分 本地化的 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.

将表单的 Localizable 属性设置为 True(您必须在设计时这样做)并为应用程序中的所有控件提供本地化文本有什么问题?Windows 窗体实际上对本地化提供了相当全面的支持;设计器会自动将所有可本地化的元素序列化到表单的 RESX 文件中.请参阅 MSDN:演练:本地化 Windows 窗体.确保留出足够的空间以允许不同语言中不同长度的表达式.

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.

这篇关于WinForms 中是否有本地化常用文本的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:WinForms 中是否有本地化常用文本的存储库?

基础教程推荐