Skip to main content
A newer version of this page is available. .

Localize WinForms Dashboard Designer and Dashboard Viewer

  • 5 minutes to read

The topic describes how to localize different UI elements such as dialog boxes, button captions, menu items, error messages. You can localize the WinForms Dashboard Designer and Dashboard Viewer’s user interface with satellite resource assemblies and localizer objects.

Localization_LocalizedDesigner

Tip

See the main Localization topic for information on how to localize culture-specific data.

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

Use the DevExpress Localization Service to obtain satellite assemblies for DevExpress .NET controls that correspond to other cultures. Copy the folders (for example, es or de) that contain satellite assemblies to the application’s bin folder.

Refer to Localize WinForms Controls via Satellite Resource Assemblies for a detailed guide.

Specify a Culture Different from the System Culture

Assign the required culture’s abbreviation to the CurrentThread.CurrentUICulture and CurrentThread.CurrentCulture properties to specify a culture for your dashboard application:

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.

Important

We recommend that you localize UI using resources because some components contain form resources (for example, the “Export to PDF” dialog), which should be translated with satellite assemblies. Use the Localizer classes to translate specific strings.

Follow the steps below to localize your application with this approach:

  1. Create a descendant of the localizer class.

    Two specific types of Localizer objects are available for the Dashboard Suite WinForms UI:

    Use the DashboardLocalizer and DashboardsResLocalizer classes respectively to localize cross-platform strings.

  2. 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.
  3. 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.

Localization_WinLocalizer_Example

Tip

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

See the following topic for general information: Localize WinForms Controls via Localizer Objects