C# 中的多语言消息框

发布于 2024-08-22 13:54:07 字数 130 浏览 3 评论 0原文

我必须用 C# 3.5 制作一个多语言桌面应用程序。我知道如何在设计时为标签添加多语言文本。

但我无法找到如何使消息框和确认对话框成为多语言?我是否必须在代码中添加 if/else 条件来检查所选语言?

感谢期待!

I have to make a multi-lingual desktop application in C# 3.5. I know how to add multilingual text for labels at design time.

But I am unable to find how to make Messagebox and Confirm dialogs multilingual? Do I have to add if/else conditions in code to check the selected language?

Thanks in anticipation!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏璃陌 2024-08-29 13:54:07

您需要将标题和消息字符串移至资源中,然后通过程序集的 Properties.Resources 类上自动生成的属性来访问它们。

可以通过查看项目属性并单击“资源”选项卡来创建项目的主资源文件。如果您的项目还没有 Resources.resx,该选项卡上将会有一个用于创建一个的链接。创建后,您可以添加项目范围的资源,例如图像和字符串。

You need to move the caption and message strings into resources and then access them via the auto-generated properties on the Properties.Resources class for your assembly.

The main resource file for a project can be created by viewing the project properties and clicking the Resources tab. If you don't already have a Resources.resx for your project, there will be a link on that tab to create one. Once it is created, you can add project-scoped resources such as images and strings.

完美的未来在梦里 2024-08-29 13:54:07

您应该使用资源。 (可以在项目 -> 属性... -> 资源选项卡中找到)

如果您使用资源选项卡,则 VisualStudio 将在 Properties 文件夹中创建 Resources.resx 文件您可以在其中存储不同类型的资源。 (例如图像、音频和字符串)
您可以在其中添加任何可本地化的字符串并稍后使用它们,例如 Properties.Resources.MyMessageBoxTitle

稍后,当您想要添加对另一种语言的支持时,您可以复制该 Resources.resx 文件并将其重命名为 Resources.it-it.resx (或 >Resources.fr.resx)。然后资源管理器将自动从相应的资源文件加载该字符串。 (基于Thread.CurrentUICulture

You should use Resources. (Can be found at Project -> Properties... -> Resources tab)

If you use Resources tab then VisualStudio will create Resources.resx file in Properties folder for you where you can store different type of resources. (e.g. Images, Audio and Strings)
You can add any localizable strings there and use them later like Properties.Resources.MyMessageBoxTitle.

Later when you want to add a support for another language you can copy that Resources.resx file and rename it to something like Resources.it-it.resx (or Resources.fr.resx). Resource manager then will automatically load the string from a corresponding resource file. (based on Thread.CurrentUICulture)

命比纸薄 2024-08-29 13:54:07

在设计器中,在父窗体或控件上,有一个名为 Localizable 的属性,将其设置为 true,然后,您可以更改它的 Language 属性并更改标签/移动进行控制以使布局适合该本地化。

这样做将相应地创建资源文件。

In the designer, on the parent form or control, there is a property called Localizable, set it to true, then, you can change it's Language property and change labels/move controls around so that the layout fits for that localization.

Doing so will create resource files accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文