1

I have a problem of understanding with localization, hope you can help.

I create a winform app:

  1. add a button
  2. set the form Localizable property to True
  3. set the form Language to Spanish
  4. change the button's Text to "Vamos" and BackColor to "Green".
  5. set the form Language to English
  6. change the button's Text to "Go" and BackColor to "Yellow".

When I swap between Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("es"); and Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en"); the button Text DOES change from "Vamos" to “Go” but the BackColor is always set to “Yellow”.

My deduction is that Localizable = True tracks [control].Text property changes, and other changes such as [control].Location and [control].Size, but it does NOT track [control].BackColor or many other control property changes in the respective resx files.

Is this a bug? Is there a reference document to understand what IS and ISN'T being tracked? I can understand that BackColor is not something that is typically related to a language change but on that basis, size and location shouldn’t be either...so I am not clear on the rationale applied here...

Because of this limitation I am having to make certain localization changes via resx files and others manually via my on logic, feels a bit messy.

Thanks for your help. [tested in VS 2012 and 2017 with equal behaviour]

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
leoinlios
  • 831
  • 2
  • 9
  • 17

1 Answers1

1

A property is considered as localizable if it's decorated with Localizable(true) attribute. For example BackColor property is not localizable, but Text property is localizable.

When the designer generates code for your form, when you have enabled localization for the form, properties which are decorated with the Localizable(true) will be serialized to the resource file of the form. For the rest of the properties, their values will be serialized in code.

For more information and links to how to create multi-language windows forma application, take a look at:

leoinlios
  • 831
  • 2
  • 9
  • 17
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
  • thanks for the explanation. I can see that Text has attribute "Localizable(true)" and BackColor does not. Can you please explain what you mean by "For the rest of the properties, their values will be serialized in code."? For non-localisable properties I do not see VS doing anything at all for me. – leoinlios Dec 31 '18 at 13:46
  • You're welcome. Responsibility of the Windows Forms designer is serializing the form and its controls into the designer.cs file. For example when you are designing `Form1.cs`, it serializes the form and controls in `Form1.Designer.cs`. For localizable properties, you can see values of the properties are serialized in `Form1.resx` and for non-localizable properties, values are serialized in `Form1.Designer.cs`. – Reza Aghaei Dec 31 '18 at 13:51
  • 1
    makes sense. Thanks – leoinlios Jan 01 '19 at 17:37