Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何本地化windows窗体字符串中的内联字符串?_C#_Localization_Windows Forms Designer - Fatal编程技术网

C# 如何本地化windows窗体字符串中的内联字符串?

C# 如何本地化windows窗体字符串中的内联字符串?,c#,localization,windows-forms-designer,C#,Localization,Windows Forms Designer,我想本地化我的C#windows窗体应用程序。我通过逐个设置控件的语言和值来本地化控件上的字符串,并且我有form1.en.resx和form1.fr.resx,当我运行它时,它会按照我的预期工作(法语在法语pc中,英语在英语pc中)。但是我不知道如何对代码中的其他字符串执行该操作。假设我有: MessageBox.Show("Hello world"); 我想我需要像这样的东西 MessageBox.Show(Resources.Helloworld); 根据pc的语言,它应该像其他控制文

我想本地化我的C#windows窗体应用程序。我通过逐个设置控件的语言和值来本地化控件上的字符串,并且我有form1.en.resx和form1.fr.resx,当我运行它时,它会按照我的预期工作(法语在法语pc中,英语在英语pc中)。但是我不知道如何对代码中的其他字符串执行该操作。假设我有:

MessageBox.Show("Hello world");
我想我需要像这样的东西

MessageBox.Show(Resources.Helloworld);
根据pc的语言,它应该像其他控制文本一样选择正确的资源值。做这种事的正确方法是什么

我尝试了resharpers
移动到资源
选项。但它只移动到项目的资源,所以我不能在上面指定任何语言选项


任何帮助都将不胜感激。

您可以尝试以下方法:

  public enum myResource
    {
        HelloWorld,
        ByeWorld
    }



public string GetText(myResource someRes)
        {
            string sText = "";
            switch (someRes)
            {
                case someRes.HelloWorld:
                    sText = "Hello World";
                    break;
                case someRes.ByeWorld:
                    sText = "ByeWorld";
                    break;
                default:
                    sText = "Empty...";
                    break;
            }

            return sText ;

        }

[这个链接][1]正是我一直在寻找的。谢谢[1]: