Multilingual SSRS reports – Scenario 2: Change RDL
August 20, 2013
This is the third post in my series about multilingual SSRS reports. If you missed the introduction, you can find it here.
In this post we will talk about the second implementation scenario, which changes the RDL after creating it. The diagram below helps to understand this:
This means that developing the report is independent of making it available in multiple languages. This means there is no impact on the process of creating a report, where with the first scenario (custom assembly) there was an impact (and a rather big one!).
The downside of this solution however is that there will be a separate process manipulating the RDL after it has been developed. This has a downside however: if the RDL language schema changes (and it does just about every new release of SQL) you will have to check if your code still works.
Now, the process that changes the RDL could do two things: 1) change the original RDL and add localization that will actually localize the report at run time or 2) change the original RDL and make a copy of it for every language (essentially you get the same report multiple times).
The first option here is just an automated version of scenario number 1 (the custom assembly) which we discussed earlier. It however eliminates the biggest issue with scenario 1: the fact that it is a manual process and has to be repeated for every label. However, what this option doesn’t do is allow you to translate parameter prompts, which option 2 does. Downside of option 2 however is that multiple copies of the report get created (one for each language). Creating multiple copies of the report (one for each language) would have no impact on rendering the report and may be a good choice if you want to manage each language separately. You will need to decide for yourself what you want to do, the basic architecture of this scenario stay the same.
In this post we will deal with the latter option (option 2).
I envision the process that changes the RDL as just a process that gets executed periodically. The process reads the RDL and translates any text it finds again using the translation table, resource file or whatever solution you picked for storing translations.
Implementing the process is out of scope for this blog because it is a matter of reading an XML file (RDL is XML structured) changing some items and writing it to disk. Any .NET developer could do it, for example using XPath.
The trick of course is knowing what to find in the RDL and what to change.
The simplified structure of RDL (SQL 2012) is the following (I stripped away all that is not related to localization):
As you can see, there a just a couple of items we need to look for when scanning the RDL:
Report.DataSets.DataSet DataSets define the queries to the source systems. If we want to localize result sets we need to manipulate the query here.
Report.ReportSections.ReportSection.Body.ReportItems / Report. ReportSections.ReportSection.Page.PageHeader.ReportItems / Report. ReportSections.ReportSection.Page.PageFooter.ReportItems ReportItems can be TextBox, Chart, Tablix, which will be discussed in more detail later.
Report.ReportParameters.ReportParameter Parameter prompts can be localized here.
Localizing a DataSet A dataset defines the <CommandText> which essentially is the query to the source system. When changing the RDL one can easily add a where-clause to the query indicating the language to render:
What you will be looking for is Report.DataSets.DataSet.CommandText to do this.
Localizing ReportItems ReportItems can be TextBoxes, Charts, and Tablixes each of which carry one or more labels that need localization. The structure of a TextBox looks like this:
You will be looking for the ReportParameter.Prompt tag.
That concludes our overview of changing the RDL to implement localization. I agree it is not the most elegant solution as it increases dependency and complexity in your environment, however it is fairly simple to implement and provides a complete localization opportunity, from datasets to report items and even parameter prompts.