Localization of Bold Reports® Report Viewer

To localize the Bold Reports® WPF Report Viewer for a specific culture, add a resource file for the culture, assign the localized values, and set the current UI culture of the application. Localization renders static text such as tooltips, the parameter block, and dialog text in that culture. Follow these steps to localize the Report Viewer.

  1. Add Resources file for the different cultures.
  2. Assign the value to each culture using key.
  3. Assign a Current UI Culture to the application.
  4. Set Report Viewer properties.

How do I add resource files for different cultures?

To add resource files for different cultures to your WPF application, create a Resources folder and add a BoldReports.Wpf.resx file to it. Follow these steps.

  1. Right-click the project and add the Resources folder in your application.

  2. Right-click on the Resources folder and pressCtrl+Shift+A keys or select Add > New Item from the context menu.

  3. In the Add New Item dialog, select Resources file and name it as BoldReports.Wpf.resx.

    Adding a new resource file

  4. Click Add.

  5. Set the Build Action to Embedded resource and Custom Tool to ResXFileCodeGenerator.

    Adding a new resource file

If another culture is used in the application, create another resource file named [AssemblyName].[CultureInfo Code].resx, following the mandatory naming convention. For example, if you are creating a resource for the fr-FR culture, you should create a new resource file named BoldReports.Wpf.fr-FR.resx and manually translate its content.

How do I assign values to each culture using a key?

To assign Values in the WPF Report Viewer resource file, update the file according to the following steps:

  1. Open the BoldReports.Wpf.resx file by double clicking it from Solutions Explorer.

  2. Add the resource key name, and its corresponding localized value by editing its field. Modify the resource values based on the fr-FR culture, as shown in the following image:

    Edit resource file

    You can download the modified fr-FR resource file and replace it in your application.

How do I assign the current UI culture to the application?

To make the WPF application use the values from the resource file, set the CultureInformation in the application before the InitializeComponent() method call. In this application, MainWindow.xaml.cs is the startup page, and the culture is assigned as in the following code:

public MainWindow()
{
    System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
    InitializeComponent();
}

How do I display the localized Report Viewer?

To display the localized WPF Report Viewer, add the Report Viewer initialization code and run the application.

  1. Add the Report Viewer initialization code.

    this.reportViewer.ReportPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Resources\sales-order-detail.rdl");
    this.reportViewer.RefreshReport();

    In this tutorial, sales-oreder-detail report is used.

  2. Run the application. The following output shows the toolbar items localized for the fr-FR culture.

    Localization output