WinForms Data Grid

User Interface Localization

 

Developer Express .NET products have always been designed and developed bearing in mind that you may require the need to localize your application for different markets. The XtraGrid Suite is no exception in this regard.

Once you localize the XtraGrid and XtraEditors Library, your end-users will be able to see button and form captions, menu items and various element names used in the grid control and editors in their native language.

How is Localization Implemented in the XtraGrid?

There two methods you can use in order to translate strings. The first one is to create descendant Localizer classes and override their GetLocalizedString methods. The sample code below shows how you can provide German equivalents for menu options available in XtraEditors:

[C#]

public class GermanLocalizer : DevExpress.XtraEditors.Controls.Localizer {
  public override string GetLocalizedString(StringId id){
    switch(id) {
      case StringId.PictureEditMenuCut: return "Ausschneiden";
      case StringId.PictureEditMenuCopy: return "Kopieren";
      case StringId.PictureEditMenuPaste: return "Einfügen";
      case StringId.PictureEditMenuDelete: return "Löschen";
      // ...
    }
    return "";
  }
}

Then assign your localizer class instance to the static DevExpress.XtraEditors.Controls.Localizer.Active object and all your editors will now use the translated strings.

[C#]

Localizer.Active = new GermanLocalizer();

For XtraGrid localization, you need to create a
DevExpress.XtraGrid.Localization.GridLocalizer class descendant, override its GetLocalizedString method and then assign a class instance to the static DevExpress.XtraGrid.Localization.GridLocalizer.Active property:

The second localization method lies in the fact that XtraGrid fully supports the resource model introduced by the .NET Framework. The main advantage of this method is that it allows you to separate application executable code from resources used by controls. For instance, you can deliver applications to your end-users and supply or modify regional-specific resources later without changing the main application.

To do this, you first need to translate XtraGrid resources into a specific language and name it according to the desired language/region. Then compile the resources into a dynamic library and deploy it based on .NET Framework conventions.

In order to load and use specific language resources in your application, you need to enable the corresponding language and then recreate Localizer objects which are responsible for reading resources and supplying them to the XtraGrid and XtraEditors.

Refer to the XtraEditors help file shipped with the installation to obtain step-by-step instructions on creating localized resources for XtraEditors. XtraGrid can be localized in a similar manner.

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.