0

I want to localize my C# windows forms application. I handled to localize the strings on controls by setting their language and values one by one, and I have form1.en.resx and form1.fr.resx and when I run it works as I expected (french in french pc's english in english pc's). But I couldn't find out how will I do that for other strings in the code. Let's say I have:

MessageBox.Show("Hello world");

I believe I need something like

MessageBox.Show(Resources.Helloworld);

And according to the language of the pc it should select the rigth resource value as other control texts do. What is the rigth way to do such a thing?

I tried resharpers Move to resource option. But it only moves to resource of the project hence I cannot specify any language option on it.

Any help would be appreciated.

Tolga Evcimen
  • 7,112
  • 11
  • 58
  • 91
  • [This link][1] is really what I've been looking for. Thanks. [1]: http://stackoverflow.com/questions/1142802/how-to-use-localization-in-c-sharp – Tolga Evcimen Sep 25 '13 at 10:03

1 Answers1

0

You could try something like this:

  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 ;

        }
Sadique
  • 22,572
  • 7
  • 65
  • 91