Gaby
Gaby

Reputation: 3033

How to localize UserControl

I'm developing a windows application that must support multiple language.

I've followed the article below http://msdn.microsoft.com/en-us/library/y99d1cd3(v=vs.71).aspx to make my windows application localizable.

Everything works fine except the usercontrols. Do i have to create a usercontrol for each language? How to make the usercontrol inherit the Right to left property? What is the best practice to do it?

Upvotes: 5

Views: 2750

Answers (2)

gcode
gcode

Reputation: 2989

There are two components to making a User Control localizable, and editable in the Visual Studio Designer:

  1. Set the top Form object's Localizable property to True
  2. Define control properties that you want to localize and edit in the Designer like so (borrowed from here):

C#

[Category("Appearance")]
[Description("The title of the log data.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Localizable(true)]
[HelpKeywordAttribute("AttributesDemoControlLibrary.AttributesDemoControl.TitleText")]
public string TitleText
{
    get
    {
       return this.label1.Text;
    }

    set
    {
          this.label1.Text = value;
     }
}

You may need to toggle the Localizable property and clean/rebuild your Solution before the data is reflected in the Resource file.

Upvotes: 0

Tobia Zambon
Tobia Zambon

Reputation: 7619

UserControls have to be localized in the same way as forms (Localizable = True, Language = ...), you don't see the localization in the designer when they are embedded into a localized Form but during the runtime the localization is done well.

For the RightToLeft property: select your UserControl (select a control inside it and press ESC until the main control is selected - in the property panel you should see the name of your UserControl and the type = System.Windows.Forms.UserControl), go to the property panel and search for the RightToLeft property, in the same panel you have also the Localizable and Language property that has to be used as you do in Forms.

Upvotes: 2

Related Questions