- 5 minutes to read
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.
This is the default localization technique for DevExpress Reporting controls v20.1 or later. Previous versions use satellite assemblies.
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:
You can also localize the following attributes of reports and report controls:
- value formatting
- 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:
Use the Property Grid to set the report’s Language property to a value other than Default.
In the Property Window, click the Localizable Properties toolbar button to display only localizable properties in the Property Grid (see the image below).
Change the control’s localizable property values. You can also move and resize the control.
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:
Specify the report’s culture. The method depends on the application platform:
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.
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.
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.
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.
Invoke a preview window or use a Document Viewer control to load a localized report. Refer to the following topics for more information:
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:
The following properties are localizable: