Localize Reports
- 5 minutes to read
Overview
This document describes how to localize a report that targets different languages and cultures.
This method 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 method is the default for reports in v20.1 or later. Previous versions use satellite assemblies.
Tip
Review the Vehicle Inspection Report WinForms demo to see the localized report.
A localized report can display text based on different cultures. The following text properties can be localized:
- XRControl.Bookmark
- XRControl.NullValueText
- XRControl.Text
- XRControl.TextFormatString
- Parameter.Description
- XRTableOfContentsTitle.Text
- XtraReport.DisplayName
Tip
- Use the Text property to localize controls that display static text.
- Use the TextFormatString property to localize data-bound controls in Expression Bindings mode.
To display translated text in a localized report, adjust the following attributes of your reports and individual 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:
Use the Property Grid to set the report’s Language property to a value other than Default.
To display only localizable properties in the Property Grid, click the Localizable Properties toolbar button in the Property Window as demonstrated in the picture below.
Change the control’s localizable property values. You can move and resize a 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 a 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.
Refer to the
WinForms Application: Select a Culture Different from the System Culture document for more information.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. Review the Globalization and localization in ASP.NET Core topic for more information.
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. Refer to the
WPF Application: Select a Culture Different from the System Culture document for more information.Tip
You can set different languages to the Viewer UI and the report displayed in the Viewer. Handle the report’s BeforePrint event and call the XtraReport.ApplyLocalization method that allows you to specify a culture and localize a 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:
- Band.HeightF
- Parameter.Description
- VerticalBand.WidthF
- XRCharacterComb.CellHeight
- XRCharacterComb.CellHorizontalSpacing
- XRCharacterComb.CellVerticalSpacing
- XRCharacterComb.CellWidth
- XRControl.Bookmark
- XRControl.Font
- XRControl.LocationFloat
- XRControl.NullValueText
- XRControl.SizeF
- XRControl.Text
- XRControl.TextFormatString
- XRControl.Visible
- XRCrossBandControl.EndPointFloat
- XRCrossBandControl.StartPointFloat
- XRCrossBandControl.WidthF
- XRTableCell.Weight
- XRTableOfContentsLevelBase.Font
- XRTableOfContentsTitle.Text
- XRTableOfContentsTitle.TextAlignment
- XRTableRow.Weight
- XtraReport.DisplayName
- XtraReport.Margins
- XtraReport.PaperKind