Description:
I've created an application using DevExpress WinForms components. How do I localize it?
Answer:
All the default strings used in our components (captions of built-in forms, wizards, buttons' texts, etc.) can be localized using our Localization Service or Localizer Objects.
Please refer to the How to localize DevExpress .NET controls and How to translate components via their Localizer objects KB articles for more information.
However, when developing and designing your application, you customize almost every component you are adding to your forms and user controls. To translate texts of components you are setting at design time and adapt layouts of your forms and user controls for different cultures, you need to localize them. WinForms provides an out-of-the-box approach to localize forms and it is described in the Walkthrough: Localizing Windows Forms MSDN article. This approach is applicable to our components as well.
You need to perform two actions to make your forms localizable:
- Set the form's Localizable property to True.
- Select a language using the form's Language property.
After saving your form, Visual Studio will generate an additional resource (.RESX) file in the following format:
C#TestForm.de-DE.resx
where the de-DE part indicates culture code:
Text, size, location and other settings are saved in the .resx file.
An application culture is determined by the CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture properties.
These settings and thus resource files are applied automatically depending on culture settings of the system your application is run on.
The following pictures illustrate the results:
default (en-US) culture
German (de-DE) culture:
As you can see, Text, Size and Location of the button are automatically changed.
Please note that resources are not applied automatically when an application culture is changed at runtime. The correct way to do it is to restart your application.
IMPORTANT NOTE:
If you are facing issues using the standard WinForms localization mechanism, please review the Localization - How to avoid issues when localizing DevExpress WinForms components using the standard WinForms localization mechanism article were we collected information about known issues.
See also:
Walkthrough: Localizing Windows Forms
How to localize DevExpress .NET controls
How to translate components via their Localizer objects
Localization Service
Localization