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. Call the XtraReport.SaveLayout method to save localized strings in REPX format with the report’s layout.
To view the localized report, refer to the following DevExpress WinForms demo:
A localized report can display text based on different cultures. You can localize the text properties in the Lolization Editor.
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
For the full list of localizable properties, refer to the following section: Localizable Properties.
How to Localize a Report
To localize a report, follow the steps below:
Use the Properties window 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 Properties window (see the image below).
Change the control’s localizable property values. You can also move and resize the control.
You can use the Localization Editor to change text in the report and expedite the translation process.
Save the report.
When a Document Viewer loads a localized report, the document contains modifications that match the application’s culture.
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.Call the XtraReport.ApplyLocalization method. As an alternative, you can specify the current thread locale, but note that an XtraReport instance is created in the main thread of the application, while the report document creation is performed in a separate thread. This means that you should specify the culture of the current thread before creating the document. 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.
Call the XtraReport.ApplyLocalization method. As an alternative, you can specify the current thread locale, but note that an XtraReport instance is created in the main thread of the application, while the report document creation is performed in a separate thread. This means that you should specify the culture of the current thread before creating the document. For more information, review the following help topic: Globalization and localization in ASP.NET Core.
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.
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:
XtraReport
Parameters
- Parameter.Description
- LookUpValue.Description
GroupLayoutItem.Title
XRControl
- XRControl.Bookmark
- XRControl.Font
- XRControl.LocationFloat
- XRControl.SizeF
- XRControl.Text
- XRControl.Visible
XRChart
- AxisTitle.Text
- ChartTitle.Text
- ConstantLine.LegendText
- ConstantLineTitle.Text
- CustomLegendItem.Text
- EmptyChartText.Text
- Indicator.LegendText
- LegendTitle.Text
- PaneTitle.Text
- SmallChartText.Text
- SeriesTitle.Text
- Series.LegendTextPattern
- SeriesLabelBase.TextPattern
- Strip.LegendText
- Strip.AxisLabelText
- TextAnnotation.Text
- Properties that can be localized for a chart series are also available for SeriesTemplate.
XRCharacterComb
- XRCharacterComb.CellHeight
- XRCharacterComb.CellHorizontalSpacing
- XRCharacterComb.CellVerticalSpacing
- XRCharacterComb.CellWidth