Skip to main content Skip to footer

Runtime Localization in ActiveReports

Why Do We Need Localization?

Localization plays an important role if a report has been designed to target an audience which is not restricted to a single region/culture. ActiveReports 8 provides rich support for localization both at design time as well as run time. This expands the range of users who can access the report and more importantly can understand it properly.

Our Options

Normally localization is done while designing the report by changing the text on the controls and saving them in the resource files. However, it is also possible to choose the fields which you need to localize on the report once the report is run. In this blog article, I will present how you can localize report content at run time and also switch the view between different locales. Let us first see how our main form will look like once we have completed our application. This form contains a combobox to select the report we want to display (just in case there is more than one report). Another combobox will select the language we want to localize the report to. By default it contains only English as the available locale; however more languages are added to it as you go on adding more localized text on the second form. LoadFormOnce we are ready to localize the report text, we will click the button and this will open another form which will list the default text for all the controls present in the report. We will then update the strings as required and provide a name for the new culture. Here is how it looks. LocalizeFormFinally once the localized strings are set, we can click the OK button and the localized text will be applied to the report. Also the newly added language option would be added to the "Available Languages" list which will enable easy navigation between different languages. This is how the report will look after the text has been localized. LocalizationApplied

Implementation

I am not writing any code in this blog post since it will take take up some space and add unwanted length to the page. Rather I would like to provide a small summary of how things would be set up. In this project we have a class ReportDef which contains information about the ReportName and the language information for this report. First we add the information about the reports which we have in our project. In this example we have two reports. Since we need to get the text from the controls present in the report, we use reflection to access the text property of the controls and check all the sections and the controls contained in those sections. This is later displayed to the user so that he/she may update the strings with the localized ones. Finally, the language and the report changes are trapped in the SelectedIndexChanged for the comboboxes and respective settings are applied to the report.

See it in Action!

A complete sample which showcase this implementation can be downloaded from the link below: Download Sample Check out the video which shows the working of this sample. Localize

MESCIUS inc.

comments powered by Disqus