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

Localize Reports

  • 5 minutes to read

Overview

This document describes how to localize a report that targets different languages and cultures.

The localization technique described in this topic uses localized strings serialized with the report layout. You can call the XtraReport.SaveLayout method to save localized strings in REPX format with the report’s layout.

Note

This is the default localization technique for DevExpress Reporting controls v20.1 or later. Previous versions use satellite assemblies.

Tip

To view the localized report, refer to the following DevExpress WinForms demo: Vehicle Inspection Report.

A localized report can display text based on different cultures. You can localize the following text properties:

Tip

  • Use the Text property to localize controls that display static text.
  • Use the TextFormatString property to localize data-bound controls.

You can also localize the following attributes of reports and report controls:

  • visibility
  • size
  • location
  • value formatting
  • margins
  • paper kind

How to Localize a Report

To localize a report, open it in the Report Designer and specify a report language other than Default. Change the text, size, and location of reporting controls, and save the report. All language-specific changes are saved with the report. When a Document Viewer loads a localized report, the document contains modifications that match the application’s culture.

To localize a report, follow the steps below:

  1. Use the Property Grid to set the report’s Language property to a value other than Default.

  2. In the Property Window, click the Localizable Properties toolbar button to display only localizable properties in the Property Grid (see the image below).

  3. Change the control’s localizable property values. You can also move and resize the control.

  4. Save the report.

You can use the Localization Editor to change text in the report and expedite the translation process.

Quick Access to Localized Versions

To determine whether a report contains localized settings, or to access the localized version, use the Localization -> Language drop-down list.

How to Preview a Report in the Specified Locale

The Report Designer always loads a report in the Default language. You can change the language in the Localization Editor or set the report’s language as described in the previous section. Then, switch to the Preview tab to view the localized document.

To preview a localized report in your application, use one of the following methods:

  1. Specify the report’s culture. The method depends on the application platform:

    All Platforms

    Call the XtraReport.ApplyLocalization method before the XtraReport.CreateDocument method. You can also handle the report’s BeforePrint event and call the XtraReport.ApplyLocalization method in the event handler.

    The language parameter in the ApplyLocalization method has priority over the current thread’s culture.

    WinForms

    If you do not call the XtraReport.ApplyLocalization method, specify the culture of the current thread prior to document creation. For this, use the static Thread.CurrentThread.CurrentCulture property. The report creates a document in the current thread’s culture. The Thread.CurrentThread.CurrentUICulture property allows you to set the Document Viewer UI language.

    For more information, refer to the
    following help topic: WinForms Application: Select a Culture Different from the System Culture.

    ASP.NET MVC and Web Forms

    If you do not call the XtraReport.ApplyLocalization method, specify the culture of the current thread prior to document creation. ASP.NET MVC and Web Forms applications can use methods described in Microsoft’s Globalization, Internationalization and Localization section.

    ASP.NET MVC and Web Forms applications can also implement a custom IGlobalizationService interface and register a service to specify the current thread locale. This method applies to requests processed by DevExpress HTTP handlers.

    ASP.NET Core

    If you do not call the XtraReport.ApplyLocalization method, specify the culture of the current thread prior to document creation. For more information, review the following help topic: Globalization and localization in ASP.NET Core.

    WPF

    If you do not call the XtraReport.ApplyLocalization method, specify the culture of the current thread prior to document creation. Use the static Thread.CurrentThread.CurrentCulture property to set a report’s culture. The static Thread.CurrentThread.CurrentUICulture property allows you to set the Document Viewer UI language. For more information, refer to the
    following help topic: WPF Application: Select a Culture Different from the System Culture.

    Tip

    You can set the Viewer UI and the report displayed in the Viewer to different languages. Handle the report’s BeforePrint event and call the XtraReport.ApplyLocalization method. This method allows you to specify a culture and localize the report.

  2. Invoke a preview window or use a Document Viewer control to load a localized report. Refer to the following topics for more information:

Localizable Properties

A localized report contains localization items - objects that combine the control, language, property and value. If a value does not relate to any language, it is attributed to a default language. Localization items are contained in the XtraReport.LocalizationItems collection.

Localizable properties are annotated with the DevExpress.XtraReports.Localization.XRLocalizableAttribute custom attribute:

[XRLocalizable(true)] The following properties are localizable: