The resources in the project file in VS2008 are “creatively propagated” by the form designer, what can be avoided?

In our project in Visual Studio 2008 there are several files generated by the auto-generator, with some localized versions, and in one of these localized versions there is a line that is empty in this case.

More explicit. We have a core resource file with lots of string resources. Then we have 4 more localized versions of this file, and in one of these other localized files one of the lines is assigned an empty value.

Now the problem is that the form designer is quite happy that he has found a resource for the line and, apparently, will not stop at all, to reuse this resource for any empty lines, he will assign a property in the generated constructor code for the form.

For example, if for some reason the property in the control is not specified with a default value (therefore, it will be serialized for the code, even if it is empty), then it will refer to our resource instead of writing an empty string literally in C code #.

The problem is that it refers to localized versions, and they are not compiled for the code.

Here is an example of abbreviated code:

this.rpAllFields.KeyTip = global::namespaces.SystemMessagesResources_sv_SE. dash_red_shift_info_description; 

In this case, dash_red_shift_info_description does not matter for the sv-SE locale, so the developer, when he sees an empty line in the code, will try to bind this resource. But SystemMessagesResources_sv_SE is not an existing class, but apparently the generated class name for the Swedish localized version of the SystemMessagesResources resource file that is compiled into the class.

Can this be avoided? We are tired of searching / replacing every time we change something in the form files, and we are pretty sure that we did this to make it happen, but we apparently are not able to find the reason for this ourselves.

The above code, if we deleted the resource, read like this:

 this.rpAllFields.KeyTip = ""; 
+4
source share
4 answers

You can try to create a string resource empty_string, defined as "" for each locale. If you make this the first resource, the form designer (hopefully) always selects it as a value to sprinkle on your forms. That way, at least you'll use a string designed for this purpose.

+2
source

If the problem is caused by an empty line in the resource file, what will be the effect of its creation. Therefore, instead of “the resource file contains“. ”I don’t know if this is the best solution, but I would be interested to know if the developer would like to use this resource as an empty string by default. However, not knowing how it is used, I'm not sure what influence has a value, which must be undefined, is defined as a space ...

+2
source

How much do you need a resource whose value is an empty string? I can imagine several multilingual scenarios where some resource key should match a space in some supported languages ​​(if you use string concatenation for some user interface elements), yes.

But if the MY script was not something like this, I would simply refuse to write the resource with an empty string. I would simply say: "What is the standalone user interface text in any case translated into blank?".

If I really needed the resource to be empty in some cases (where it denotes an article in one language and where there is no equivalent word in another), I would try to see if I can produce the same effect, the way.

0
source

The generated resource file and sample code will be good.

And what are you saying: do you have an empty string literal definition in your namespace (first found), but does this cause some problems? Won't it be empty at all times? When you compile the code, it does fancy things like this to save space. I ran into a similar problem when creating XAML files using code for automated assembly of assembled files on the fly: the compiler is smart enough to know: “It doesn't matter, but for us it happened because it would rename the literals (which were used in the other place).

To get around this, we used named types for these primitives in our namespace and made it one global. I see here that your global namespace fills in the blanks - you may want to have one “lower” that evaluates all null strings.

I have not worked with this for more than a year, so forgive me if my wording is bad, but I mean: I think that XML. You need to either explicitly use the namespace in the properties, or assign them below (for example, a nested property in xaml).

I hope this helps (and makes sense)

0
source

All Articles