Skip to main content

Localize WPF Dashboard Control

  • 4 minutes to read

You can localize your applications - update their UI to match certain culture and language settings:

  • Translate UI element captions to a different language: dialog boxes, buttons, menu items, error messages, etc.
  • Format numbers, dates, and currencies according to specific culture settings.

localization-localized-wpf-control

Localize UI

You can localize the WPF Dashboard Control’s user interface with satellite resource assemblies and localizer objects.

Satellite Resource Assemblies

To localize the WPF Dashboard Control, add satellite assemblies to your application and specify the culture in code.

Obtain and Add Satellite Assemblies

The .NET Products Installer includes resource assemblies for a set of languages. It registers these assemblies into the GAC (Global Assembly Cache) of your development machine, and also places them in the installation folder (the default path is C:\Program Files\DevExpress 24.2\Components\Bin\Framework\). You can find these assemblies within the following subfolders:

Subfolder name Culture
de German
es Spanish
ja Japanese

To download satellite assemblies for other cultures, use the DevExpress Localization Service. This service allows you to modify existing translations, and compile and download satellite assemblies.

Modules to translate:

  • Dashboard.Core
  • Xpf.DocumentViewer.Core

Copy the folders (for example, es or de) that contain satellite assemblies to the application’s EXE file directory.

Refer to the following topic for a detailed guide: Localize WPF controls using Satellite Resource Assemblies

Specify a Culture Different from the System Culture

Assign the required culture’s abbreviation to the CurrentThread.CurrentUICulture and CurrentThread.CurrentCulture properties before the InitializeComponent method:

public partial class MainWindow: ThemedWindow { 
    public Form1() { 
        var culture = System.Globalization.CultureInfo.CreateSpecificCulture("de-DE");
        System.Threading.Thread.CurrentThread.CurrentCulture = culture;
        System.Threading.Thread.CurrentThread.CurrentUICulture = culture;

        InitializeComponent(); 
        // ...
        } 
    } 
} 

Localizer Objects

Localization means translating UI texts into a different language. The DevExpress WPF Dashboard control can use the DashboardLocalizer descendant to change localizable texts at runtime. This approach can be useful when a resource value is not known at design time, or if you need to set the resource value based on a runtime condition.

Use the following localizer objects to translate resources:

Important

We recommend you to localize UI using resources because some components contain form resources, which should be translated with satellite assemblies. Use the Localizer classes to translate particular strings.

Follow the steps below to localize the DashboardControl:

  1. Create a DashboardLocalizer descendant and override the GetLocalizedString method (which returns a string for a specified string resource identifier) or the PopulateStringTable method.

  2. Assign an instance of this class to the static DashboardLocalizer.Active property.

The following example demonstrates how to localize the Dashboard control UI into Spanish.

  1. Implement a Localizer descendant:
using DevExpress.DashboardCommon.Localization;
// ...
    public class MySpanishDashboardLocalizer : DashboardLocalizer
    {
        public override string Language { get { return "Español"; } }
        public override string GetLocalizedString(DashboardStringId id)
        {
            switch (id)
            {
                // ...
                case DashboardStringId.ActionExportToImage: return "Exportar a";
                case DashboardStringId.ActionExportToPdf: return "Exportar a imagen";
                case DashboardStringId.ActionMaximizeDashboardItem: return "Maximizar";
                // ...
                default:
                    return base.GetLocalizedString(id);
            }
        }
    }

Instantiate the custom localizer and assign it to the static Active property of the base class.

using DevExpress.DashboardCommon.Localization;
// ...
    DashboardLocalizer.Active = new MySpanishDashboardLocalizer();

Tip

You can use a simple application WPF Dashboard Localized String ID Visualizer to determine the correct name of the localized string ID enumeration member.

View Example: WPF Dashboard Control - Localized String ID Visualizer

See the following topic for general information: Localize WPF controls using Localizer Objects.

UI Localization Client

The UI Localization Client is a cross-platform utility that allows you to quickly identify non-translated strings of DevExpress UI controls and translate them during a debug session. The utility automatically generates a RESX file(s) with translated resources and adds it to the project.

For more information refer to the following topic: UI Localization Client.

Localize Dates, Numbers, and Currencies

Use the following members to specify the currency settings:

Identify Non-Translated Strings

  • Use our UI Localization Client tool shipped as part of your DevExpress subscription. This tool streamlines the entire localization process. You can quickly find non-translated strings and translate them during a debug session.
  • Handle the XtraLocalizer.QueryLocalizedStringNonTranslated event to collect non-localized resource strings for further translation. The event allows you to focus on strings that require translation in your application.