Somewhere else, someone states that the "Visible" Property of a control cannot be localized. This is half-true. However, the "Visible" Property has the LocalizableAttribute set to true. But this just means that the property is serialized to the resource file. I wrote a test program that has the visible property of a label set to "false" for the Invariant Culture. Making the form localizable I changed the visible property to "true" for the German culture. Now what happens if I start the program with the system set to German locale? The label stays invisible. Checking the resource file Form1.de.resx I can see that the visible property has not been serialized. But if I manually add this to the resource file:
<data name="label1.Visible" type="System.Boolean, mscorlib">
<value>True</value>
</data>
the label appears. I confess to be slightly confused. Two questions:
Edit: Maybe I need to clarify my question. My sample program is a simple form which has the default language set to invariant. I have manually added german resources through the forms designer. Program runs on a system with regional settings set to german.
Case 1
"Visible" Property of a panel added to the form:
1.) set to false in Invariant culture, true (default) in german culture. => panel is invisible
2.) set to true in Invariant culture, false in german culture. => panel is invisible (works as expected)
Apparently the value is only written to the language specific resource file if it's not the default.
Case 2
"Font" Property of a label added to the form:
1.) set to bold in Invariant culture, Property is reset to default in german culture. => label is not bold
2.) set to default in Invariant culture, bold in german culture. => label is bold
Now here the properties are serialized as expected.
Is it a bug or am I missing something?
We have received a response from Microsoft:
I can see that this can be a problem for this localization scenario, but in general case, this is the way to greatly reduce the size of a resx file, so we would not want to change this implementation. This design flaw does not meet our current bar, so this will not be fixed in the next release.
So the answer is: There is currently no solution.
This works just fine when I try it. Steps taken to test:
modified the constructor like this:
public Form1() {
System.Threading.Thread.CurrentThread.CurrentUICulture =
System.Globalization.CultureInfo.GetCultureInfo("af");
InitializeComponent();
}
The text box isn't visible when I run the form. I comment out the CurrentUICulture assignment to switch back to English: text box is visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With