使用 *.resx 和 Common.resx 的 Windows 窗体本地化
假设有很多形式:A.cs、B.cs、C.cs...
每种形式都是本地化的 - A.resx、A.NL-nl.resx 等。
这些形式包含一些特定的标签和一些常见的标签在所有形式中都使用标签。因此,特定字符串转到 A.resx (A.NL-nl.resx) 和常见字符串 - 比如说 Common.resx (Common.NL-nl.resx)
有没有办法强制表单初始化时使用资源字符串来自 A.resx 和 Common.resx 的所有公共字符串都去哪里了?当然,我可以在某些 OnLoad 方法中为表单布局项设置标题,但内置的本地化功能将丢失。
我之所以想要这样的功能,是因为有很多不同形式的常用字符串,并且管理/翻译这些 *.resx 文件会更容易。
我已经阅读了一些有关 C# 本地化的内容,但可能遗漏了一些内容。
Lets say there are bunch of forms: A.cs, B.cs, C.cs...
Each form is localized - A.resx, A.NL-nl.resx, etc.
These forms contain some specific labels and some common in all forms used labels. So specific strings go to A.resx (A.NL-nl.resx) and common ones - to lets say Common.resx (Common.NL-nl.resx)
Is there any way to force when form is initialized to use resource strings from A.resx and from Common.resx where all common strings go? Of course I could in some OnLoad method set captions for my form layout items, but then built in localization functionality would be lost.
The reason I would like such functionality, because there are lot of commonly used strings in different forms and it would much easier to manage/translate these *.resx files.
I've done some reading about localization in C#, but probably I am missing something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,我可以说:
当您将应用程序翻译成不同语言时,最后一个确实很重要,因为翻译可能确实取决于上下文。在一种表单上,默认按钮可能被命名为“确定”,而在另一种表单上,它应该被命名为“接受”。虽然在英语中,两个按钮都可能被命名为“Ok”,但在其他一些语言中,这听起来很尴尬,并且需要不同的名称。如果您对所有按钮使用相同的资源字符串,这是有问题的。
为了减轻多次翻译多个相同字符串的问题,您应该使用一些翻译软件,该软件可以保存字符串字典,并为您提供已经翻译的字符串。
From my experience I can say:
The last one really does matter, when you translate your app to different languages, because translation may really depend on context. And on one form default button may be named OK and on the other it should be named Accept. While in English both buttons may be named Ok, in some other languages, this will sound awkward, and different names will be required. This is be problematic, if you use same resource strings for all buttons.
And to mitigate the problems of translating several same strings many times, you should use some software for translator, that keep dictionary of string, and supply you with already translated ones.
资源有一个完全限定的名称。这意味着他们只有一个来源。如果您想在表单中使用 Common.resx 中的文本,则必须为此编写代码。简单的代码,但仍然是代码。
Resources have a fully qualified name. Which means they have one source. If you want to use texts from Common.resx in your form, you must write code for that. Easy code but code nonetheless.