![]() |
Database »
SQL Reporting Services »
General
Intermediate
License: The Code Project Open License (CPOL)
Localization of SSRS ReportsBy Sandeep MewaraHow to localize the SQL Server Reporting Services Reports |
C#, SQL.NET 2.0, .NET 3.0, .NET 3.5SQL 2005, Dev, Design
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
The article demonstrates the way to localize a SSRS Report. Although SSRS reports are created in Visual Studio (.NET IDE - BIDS), they can't be localized the same way as the normal VS.NET projects are localized because a resource file can't be added in an SSRS project.
Localization & Globalization are a normal requirement for any project accessed around the world. Reports being one of the important tools - one needs to support SSRS in multiple languages. This article (and attached demo projects) would help in implementing the same.
For any product whose customer base is all over the world, one needs to support localization at some stage. Reports, being one major part of any product that helps in analysing the data, too would need localization.
Initially when I heard of localizing a SSRS report, I was totally unaware of how one can do it! But though Microsoft has not provided a way to add a 'resx' file in order to localize, they have provided a way to use custom assembly and that does the trick!
A custom assembly is made that helps in retrieving the localized value for an asked parameter. Make a class library that has the required 'resx' file and a C# code file to access it based on the culture name passed.
// Method that retrieves the localized value based on the culture name passed
// param1 ("localeSensitiveResource") -> Resource that needs to be localized
// param2 ("cultureInfoName") -> Culture name in which Resource needs to be localized
// returns -> Localized Value
public static string GetString(string localeSensitiveResource, string cultureInfoName)
{
// Culture formation
CultureInfo ci = new CultureInfo(cultureInfoName);
// Value retrieved from the resource file
return LocalizationStrings.ResourceManager.GetString(localeSensitiveResource, ci);
}
Mark the class as "public static", since it will be accessed from outside and every instance uses the same 'DLL' from the same place.
//Class to retrieve the localized value
public static class LocalizedValue
{
public static string GetString
(string localeSensitiveResource, string cultureInfoName)
{
//
}
}
I have set my sample database tables such that each employee has a locale associated with them. Based on the locale, the report will be localized.
The designed report takes employee's ID as a parameter which internally finds the locale associated and then shows the report data to the user in a localized SSRS report. By default, the sample report would look like:
For every caption in the report, one needs to retrieve the localized value for it using a custom assembly made earlier. In order to do it:
Add a reference to the assembly:
Add VB code to access the class method exposed for localizing:
To localize a caption, right click the textbox and select 'Expression...". Use the custom code to get the localized value for any string. Refer 'resx' file in the library made for parameter name to pass.
=Code.LocalizedValue("REPORTHEADER", Parameters!ReportCulture.Value)
Once the caption(s) are localized using the custom code, the designer would look like:
There are few other things that one needs to keep in mind:
It's done! SSRS Report is now localized.
While going through the SSRS localization process, Microsoft article KB920769 helped a lot. (Refer here.)
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Feb 2009 Editor: Deeksha Shenoy |
Copyright 2009 by Sandeep Mewara Everything else Copyright © CodeProject, 1999-2009 Web13 | Advertise on the Code Project |