Localize WinForms Dashboard Designer and Dashboard Viewer
- 6 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.
Localize UI
You can localize the WinForms Dashboard Designer and Dashboard Viewer’s user interface with satellite resource assemblies and localizer objects.
Satellite Resource Assemblies
To localize the WinForms Dashboard Designer or Dashboard Viewer, add satellite assemblies to your application and specify a 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.1\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.
Basic modules to translate:
- Dashboard.Core
- Dashboard.Win
Dependent modules:
- DataAccess
- DataAccess.UI
- RichEdit.Core
- XtraBars
- XtraGrid
- XtraReports
- XtraRichEdit
Copy the folders (for example, es or de) that contain satellite assemblies to the application’s bin folder.
Refer to the following topic for a detailed guide: Localize WinForms 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 Form1 : RibbonForm {
public Form1() {
var culture = System.Globalization.CultureInfo.CreateSpecificCulture("es-ES");
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
InitializeComponent();
// ...
}
}
}
Localizer Objects
DevExpress products allow you to specify localization resource values 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
Not all strings can be translated with Localizers. We recommend that you use the Localizer classes to override the localization of specific strings only. Use resources to localize the UI because some components contain form resources (for example, the “Export to PDF” dialog) that should be translated with satellite assemblies.
Follow the steps below to localize your application with this approach:
Create a descendant of the localizer class.
Two specific types of Localizer objects are available for the Dashboard Suite WinForms UI:
- DashboardWinLocalizer provides default culture string values (en).
- DashboardWinResLocalizer provides localized culture string values if localization is applied using satellite resource assemblies; otherwise, it provides default culture resource string values.
Use the DashboardLocalizer and DashboardsResLocalizer classes respectively to localize cross-platform strings.
- Override the descendant’s GetLocalizedString method. This method is called for each localized string and returns the string’s value, and returns values that are contained within the DashboardWinStringId (in the DashboardWinLocalizer class) or the DashboardStringId (in the DashboardLocalizer class) resource string enumeration by default. Override the GetLocalizedString method to return your custom string values.
- Assign an instance of your class to the static Active property of the localizer class from which it was derived to use this localizer.
The following example demonstrates how to localize the UI of the Dashboard Designer into Spanish:
public class SpanishDashboardWinLocalizer : DashboardWinLocalizer {
public override string Language { get { return "Español"; }}
public override string GetLocalizedString(DashboardWinStringId id) {
string ret = "";
switch(id) {
// ...
case DashboardWinStringId.CommandNewDashboardCaption : return "Nuevo";
case DashboardWinStringId.CommandOpenDashboardCaption : return "Abrir";
case DashboardWinStringId.CommandSaveDashboardCaption : return "Guardar";
case DashboardWinStringId.CommandSaveAsDashboardCaption : return "Guardar como";
case DashboardWinStringId.CommandUndoCaption : return "Deshacer";
case DashboardWinStringId.CommandRedoCaption : return "Rehacer";
case DashboardWinStringId.CommandNewDataSourceCaption : return "Nueva Fuente de Datos";
case DashboardWinStringId.CommandEditDataSourceCaption : return "Editar";
case DashboardWinStringId.CommandDeleteDataSourceCaption : return "Eliminar";
// ...
default:
ret = base.GetLocalizedString(id);
break;
}
return ret;
}
}
public class SpanishDashboardCoreLocalizer : DashboardLocalizer {
public override string Language { get { return "Español"; }}
public override string GetLocalizedString(DashboardStringId id) {
string ret = "";
switch(id) {
// ...
case DashboardStringId.DateTimeGroupIntervalYear : return "Año";
case DashboardStringId.SummaryTypeSum : return "Suma";
case DashboardStringId.DescriptionItemArgument : return "Argumento";
case DashboardStringId.DescriptionArguments : return "Argumentos";
case DashboardStringId.DescriptionItemValue : return "Valor";
case DashboardStringId.DescriptionValues : return "Valores";
// ...
default:
ret = base.GetLocalizedString(id);
break;
}
return ret;
}
}
After this, these localizers are instantiated and assigned to the Active property of their base class.
public Form1()
{
DashboardWinLocalizer.Active = new SpanishDashboardWinLocalizer();
DashboardLocalizer.Active = new SpanishDashboardCoreLocalizer();
InitializeComponent();
}
The result of localizing the Dashboard Designer interface is shown below.
You can use the following example to determine the correct name of the localized string ID enumeration member:
See the following topic for general information: Localize WinForms 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.