Telerik Reporting R1 2017

Localizing Reports

You can localize your reports to display in the language of a specific culture. The article elaborates how to localize reports with RESX files through the Visual Studio Report Designer. Built-in localization with RESX files is not available for the Standalone Report Designer

Telerik Reporting uses a similar methodology for localization as Visual Studio uses for Windows Forms. The designer lets you define static text for the report (e.g. column headings, titles) in each language that you specify. A resource file (resx) is automatically created for each language to store translated text.  For more background information on localizing applications see the MSDN article Globalizing and Localizing Applications.

The report's initialization includes the creation of a standard System.ComponentModel.ComponentResourceManager object. At the time the resource manager is created the current thread's culture settings must be already updated in order the report to be processed with the correct resources.

Note Note

The Standalone Report Designer serializes the report definitions in XML but currently no pattern is available for localizing XML documents. Our suggestion is to create a user function that will accept resource key and optionally string report parameter specifying the culture code. Based on these parameters, localized string resources can be displayed in XML documents.

Localized documents displayed in English and Spanish (see figure below):

To localize a report:

  1. In the designer set the Report Localizable property to true.

  2. Select a Language property value from the drop down list in the properties window.

  3. Translate the static text into the desired language indicated by the Language property.

Important note Important

Items cannot be added in localization mode. After localizing the report set the Language property to (Default) to add new items.

To run a localized report:

  1. Add Threading and Globalization namespaces to your application.

  2. Set the current thread CurrentUICulture to a new instance of CultureInfo.  The CultureInfo constructor takes the culture code of the language you want to display.  For example "en-US" for United States English or "es-MX" for Mexican Spanish.

  3. Optionally you can set the CurrentCulture for the current thread to the culture code of the language you wish to display.  CurrentCulture affects dynamic data such as date, time and money formats.  The "Birth Date" column date format in the figure above shows Month/Day/Year in English, but in Day/Month/Year format in the Spanish example.

  4. Create a report source object to specify the report, and assign it to the ReportViewer.ReportSource property.

    If you are using a ReportViewer in a Windows application, call the ReportViewer.RefreshReport() method. If you are using a web viewer, let the page send the request for getting the rendered report.

Important note Important

Note that the culture settings must be applied before creating an instance of the report. This ensures the correct report's RESX file will be used on processing the document.

[C#] Setting the language at runtime
//Create new CultureInfo
var cultureInfo = new System.Globalization.CultureInfo("es-MX");

// Set the language for static text (i.e. column headings, titles)
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

// Set the language for dynamic text (i.e. date, time, money)
System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo; 

reportViewer1.ReportSource = new Telerik.Reporting.InstanceReportSource
    {
        ReportDocument = new Report1()
    };

// If this is a Windows application, refresh the report
reportViewer1.RefreshReport();