c# - 使用 C# Windows 窗体进行本地化,无法访问我的 .resx 文件

标签 c# winforms localization resources windows-forms-designer

嗨,我创建了这个 WinForm 程序。它有多种形式。

我寻找教程或其他东西来提供帮助,并在 StackoverFlow 上找到了它。 How to use Localization in C#

这确实很有帮助,但是.. 我创建了一个 ResourceString.de-DE.resx 文件并将其添加到 Properties 文件夹中。 添加了一些字符串,以便我可以测试它。并将访问修饰符更改为公共(public)。

Properties Folder

然后我想访问属性文件夹以使用 ResourceString.de-De.resx 文件。

setLanguage

但没有得到建议。

代码最终必须如下所示:

private void setLanguage()
{
   btnSwitchLanguage.Text = Properties.ResourceString.de-DE.btnSwitchLanguage;
}

我错过了什么吗?

感谢任何帮助。 :) 谢谢

最佳答案

您不需要添加Strings.resx文件,您的项目已经有资源文件Resources.resx。因此,如果需要本地化“de-DE”,您应该添加一个名称为 Resources.de.resx 的新资源文件。因此,您不仅可以在该资源文件中放入字符串,还可以放入图像、图标等。

除非您不打算从其他程序集访问此资源,否则无需将访问修饰符更改为公共(public)

NOTE: When you are working in the Visual Studio the Visual Assist suggestion will be the same for all languages, starting from Properties.Resources.

关于c# - 使用 C# Windows 窗体进行本地化,无法访问我的 .resx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69098944/

相关文章:

c# - 错误 : The given path's format is not supported

C# 无法使用 UdpClient 接收 WOL 包

c# - C# 中的指数函数

c# - Winforms checkedlistbox勾选一项

c# - 如何使用 MSAA 自动化简单的 Windows 窗体应用程序?

c# - Asp.Net Core 中的本地化

c# - 传递参数时sqldatasource的问题

c# - 根据两个数据表中的差异更改 datagridview 中的颜色?

ios - 本地化和警告 : Multiple build commands

Django 表单初始化问题 - 如何在父类(super class)中设置本地化?