Localize WPF Dashboard Control

  • 4 minutes to read

Localization adapts your application to linguistic and regional differences. You can localize the following elements:

  • different UI elements such as dialog boxes, button captions, menu items, and error messages;
  • numbers, dates, and currencies.

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 ("C:\Program Files (x86)\DevExpress 20.2\Components\Bin\Framework", by default). You can find these assemblies within the following subfolders:

Subfolder name Culture
de German
es Spanish
ja Japanese
ru Russian

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.

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

Localize Dates, Numbers, and Currencies

Use the following members to specify the currency settings: