Skip to main content

Localizer Objects

  • 4 minutes to read

DevExpress ASP.NET MVC extensions use Localizer objects to obtain strings for UI elements. You can use the following technique to override these strings at runtime:

The table below list differences in this techniques.

XtraLocalizer Technique Custom Localizer Technique
Specify strings for different products in a single event. Create a custom localizer for every localized product.
Localize form elements. Form elements cannot be localized.
Get strings that require translation in your application. You cannot get untranslated strings.

Use XtraLocalizer to Localize DevExpress Extensions

The XtraLocalizer class implements a localization-related API that allows you to translate DevExpress UI extensions and forms into different languages and develop multicultural enterprise applications.

  • The QueryLocalizedString and QueryLocalizedStringContainerResource events allow you to localize resources for all DevExpress UI extensions and their built-in data forms in your application. These events fire when a control or data form requests a resource string. Handle these events to translate or modify resource strings as needed.
  • The QueryLocalizedStringNonTranslated allows you to focus on the strings that require translation in your application. Handle this event to collect non-localized resource strings for translation.
using DevExpress.Web.Localization;
using DevExpress.Utils.Localization.Internal;
using DevExpress.Utils.Localization;
// ...
XtraLocalizer.QueryLocalizedString +=
    new EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs>(XtraLocalizer_QueryLocalizedString);
// ...
static private void XtraLocalizer_QueryLocalizedString(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
    if (e.StringIDType == typeof(ASPxEditorsStringId)) {
        if ((ASPxEditorsStringId)e.StringID == ASPxEditorsStringId.Calendar_Today)
            e.Value = "Select Today";
        if ((ASPxEditorsStringId)e.StringID == ASPxEditorsStringId.Calendar_Clear)
            e.Value = "Clear Selection";
    }
}

Implement a Custom Localizer

Follow the steps below to create a custom localizer:

Important

Form resources, such as the XtraReports Search dialog, cannot be translated via Localizer classes. Use XtraLocalizer class or satellite resource assemblies techniques to translate form resources.