FrancescoDS
FrancescoDS

Reputation: 995

visual c# internationalization

the example given here (http://msdn.microsoft.com/en-us/library/aa330254%28VS.71%29.aspx) from MSDN about internationalization does not work for me. I've used this snippet

ResourceManager rm = new ResourceManager("Resources.Form1", this.GetType().Assembly);
this.Text = rm.GetString("this.Text");

but throws me the following exception related to first line: System.Resources.MissingManifestResourceException I need to know why the first parameter of ResourceManager constructor is not good. I've tried also with "Form1". The resource file name is Form1.it-IT.resx or Form1.en-GB.resx and so on. Thanks for your help

Upvotes: 1

Views: 159

Answers (2)

Avi Turner
Avi Turner

Reputation: 10466

If you want to use a string from your resources, you can do as follows:

  • as described in this article Add the string to resources:
  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Click the Resources tab. On the Resource Designer toolbar, point to the resource view drop-down, click the arrow, and make sure it is set to Strings (which is the default). A settings grid will appear, displaying the strings maintained by that instance of the Resource Designer.

  3. Click on the Name column of the last row in the grid, which is marked with an asterisk (*).

  4. In the Name column, enter a name for the string.

  5. In the Value column, enter the string to be used as a resource.
  • In run time get the resource:

    this.Text = MyNamspace.Properties.Resources.StringResourcesName;

Another way would be to follow the instructions in this link

Upvotes: 1

Ben Van Hees
Ben Van Hees

Reputation: 383

You need a default resource file, rename Form1.en-GB.resx to Form1.resx This will be the default, and if cultureinfo is IT, the resource manager will first look in the Form1.it-IT.resx file, afterwards in the Form1.resx file if key was not found in it-IT version.

Upvotes: 1

Related Questions