Localizing Windows Forms

Release 1.0 - ...

Visual Studio offers extensive design-time support for localizing Windows Forms. To localize a Form:

  • Select the form in the Solution Explorer
  • Open the associated Properties window
  • Set the “Localizable” property to True

Visual Studio will create a resource file for the selected form with the name of the form class and the extension resx. The Solution Explorer will display the newly created resource file as a child of the form class. Any custom values assigned to localizable control properties will be stored in the resource file. When the form is loaded, the localizable control properties will be initialized from the resource file for the current culture.

Also note the form property “Language”. The initial value will be “(Default)”, meaning that the currently displayed resources belong to the Neutral Culture. The neutral culture serves as the ultimate fall-back culture. When a resource value is not available in a specific culture, then the value from the neutral culture resource is be used.

To localize the form for a specific culture, assign the name of the culture (in the form "-") to the “Language” form property. Visual Studio will create a new form resource file for the selected culture. The Solution Explorer will display the resource file as a new child of the form class. Now you localize the form for the chosen culture using the form designer. Changed property values are stored in the resource file for the active culture. Note that unchanged property values are not stored, so localized resource files only contain those resources that actually differ from the neutral/default culture.

When a form is localized, the form designer will generate code in the InitializeComponent method that creates a ComponentResourceManager instance and initializes all the localizable form control properties from resource values associated with the current UI culture.