Localization is not a build in feature in SQL Server Reporting Service (SSRS). The user experience is very important for the success of your reports. In a lot of organizations you will see people who are using their applications in different languages. A user can install\configure his windows operating system and MS Office version in the langauage he or she wants. When using SSRS reports a user can't select the language of his reports. The reports will be generated in the language they are made. This is not a good user experience. This blog will explain what you can do to support multiple languages in your SSRS reports.
1) We need a table which will hold all translations.
CREATE TABLE [dbo].[Translations](
[ID] [int] NOT NULL,
[Language] [nvarchar] (10) NOT NULL,
[Description] [nvarchar] (255) NULL,
CONSTRAINT [PK_Translations] PRIMARY KEY CLUSTERED
([ID] ASC,[Language] ASC)
) ON [PRIMARY]
2) We need to add translations to this tabe which are needed in the reports.
INSERT
INTO Translations (ID,Language,Description) VALUES (1000000,'en-US','Management')
INSERT INTO Translations (ID,Language,Description) VALUES (1000000,'nl-NL','Management')
INSERT INTO Translations (ID,Language,Description) VALUES (1000001,'en-US','Dashboard')
INSERT INTO Translations (ID,Language,Description) VALUES (1000001,'nl-NL','Dashboard')
INSERT INTO Translations (ID,Language,Description) VALUES (1000002,'en-US','Revenue')
INSERT INTO Translations (ID,Language,Description) VALUES (1000002,'nl-NL','Opbrengst')
INSERT INTO Translations (ID,Language,Description) VALUES (1000003,'en-US','Cost')
INSERT INTO Translations (ID,Language,Description) VALUES (1000003,'nl-NL','Kosten')
INSERT INTO Translations (ID,Language,Description) VALUES (1000004,'en-US','Result')
INSERT INTO Translations (ID,Language,Description) VALUES (1000004,'nl-NL','Resultaat')
INSERT INTO Translations (ID,Language,Description) VALUES (1000005,'en-US','Cash')
INSERT INTO Translations (ID,Language,Description) VALUES (1000005,'nl-NL','Liquiditeit')
INSERT INTO Translations (ID,Language,Description) VALUES (1000006,'en-US','Risk')
INSERT INTO Translations (ID,Language,Description) VALUES (1000006,'nl-NL','Risico')
INSERT INTO Translations (ID,Language,Description) VALUES (1000007,'en-US','Figures are expressed in ')
INSERT INTO Translations (ID,Language,Description) VALUES (1000007,'nl-NL','Cijfers worden weergegeven in ')
INSERT INTO Translations (ID,Language,Description) VALUES (1000008,'en-US','up to')
INSERT INTO Translations (ID,Language,Description) VALUES (1000008,'nl-NL','t/m')
3) Open a new SSRS report in Business Intelligence Development Studio. (BIDS)
4) Create a dataset which will return the set of labels for a given language. Add dataset named 'Labels' using next query:
SELECT ID, Language, Description
FROM Translations
WHERE Language = @Language
5) After adding the dataset 'Labels' a report parameter named 'Language' is added to the report. Configure the default value of the parameter 'Language' to the language ID of the client running the report.
The language ID of the client is configured by the user in Internet Explorer, Internet Options, Tab General, Button Language
6) For testing purposes it is easier to make the parameter 'Language' visible.
7) Create a second dataset with all available languages. This dataset will be used as available values for the parameter. You can use next query:
SELECT DISTINCT(Language) FROM Translations
8) Create a hidden, multi-valued parameter called 'Labels'.
Set the available values to the Labels dataset, value field: ID, label field: Description
Set the Default values to the Labels dataset, value field: ID This is important as you don't have access to tha available values from within the report. When the report is started by the user, the 'Labels' parameter will contain all translation for the selected language.
9) Add a function to the report. This function will find the translation for the selected language based on the specified ID in the report. To add a function to a report, right click on the yellow part of the report. Choose Report Properties, Code
Use next code:
Public Function GetLabel(P as Parameter, Label as String) as String
Dim i As Integer
For i = 0 to Ubound(P.Value)
If (P.Value(i) = Label) Then Return P.Label(i)
Next i
Return Label
End Function
10) Now we are ready to configure the labels in your report to use this function.
As example for translation of the label: 'Revenue' use next expresion in your label:
=Code.GetLabel(Parameters!Labels,1000002)
11) Next step is to configure the report to use the date and number format to the selected language.
Open the report properties window and configure language with the parameter value of the selected language.
=Parameters!Language.Value
12) Now execute your report. The report will be generated in the configured language of your Internet Explorer.
13) Select another language if you want, in this case nl_NL\
You will see that all labels are translated and the thousand seperator is changed from , to .
Enjoy it to make your reports in the localization of your users to improve the user experience.