Is there some way to fix the DoNotPassLiteralsAsLocalizedParameters problem, without just suppressing it?
I want it to load the strings from a resource file, and have got that working.
The problem is, that I want to have the strings from the default locale shown on the controls in the controller, so I don't have empty labels, buttons etc.
Can I do that?
I'm using C# 2.0
-
-
Come on, nobody who knows how to fix this?
-
So it has only been 9 months since you posted this! I can tell you how I fixed it in my code and you probably have figured this out by now:
using
System.Resources;
readonly ResourceManager resourceManager = new ResourceManager("{namespace that is setup in project properties}.Resources", Assembly.GetExecutingAssembly());
Under the InitializeComponent() method I changed out the existing this.Text = "My Form Name"; with:
this.Text = resourceManager.GetString("theTextNameThatIPutInResources.resx", CultureInfo.CurrentUICulture);
So what you want to do is make sure that in Resources.resx you create a new item under Strings that you will refer to in the above line of code.
All of this code should be placed in your frmName.Designer.cs partial class file.
Hope this helps anyone else who had to deal with this utilizing Code Analysis. -
Is it really a good idea to recommend that people modify a code-generated file?leitej wrote:All of this code should be placed in your frmName.Designer.cs partial class file. -
All you need to do is set the Localizable property of the form to true in the designer. Then all the localizable properties of the form and its controls will be stored in the resource files associated with the form. This will get rid of that FxCop message.
Then just change the Language property and then change all the strings etc. if you want to localize the form. Easy as strawberry pie.
That way you also don't have to write resource-loading code for the form, it's all automatic, and fully designer-supported.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.