Multilingualism in SSRS

Is there any way to display / export english SSRS report in some other languages?

+7
reporting-services multilingual report
source share
7 answers

No, unfortunately, there is no easy way to do this :-( I tried to do it and work myself, but in the end, what I did was basically pass all the shortcuts that I want to display on the report from the calling application (ASP.NET application , in my case).

Another approach could be to save text snippets in a SQL Server table and add a data source to your report that retrieves these text labels and then binds them to the appropriate controls. I tried something similar, but could not get it to work for myself.

The pain is that ASP.NET is so well internationalized in resources, but SSRS is still a rather dirty business, trying to make it multilingual :-(

+6
source share

You can open the global parameter (User! Language), which reflects the user language.

You can then use google translateapi to translate English words into your language.

Here is a great article: http://mscrm4u.blogspot.com/2008/06/multi-lingual-ssrs-reports.html

+3
source share

You should try the following link, this is the best way to do this.

http://support.microsoft.com/kb/920769

You will need to create an assembly with your resources and methods to get culture-based strings. Here you can find the complete tutorial:

http://www.codeproject.com/Articles/294636/Localizing-SQL-Server-Reporting-Services-Reports

You can add a custom assembly that contains resources for your lines that you want to translate and access them in your report.

+3
source share

I managed to get multilingual support through .NET resource files, applying an interesting hack. There is an unused property for each individual report control called ValueLocId. Using this property, you can specify a resource name for each control. The idea here is that you will iterate over the definition of your report, looking for controls that have the ValueLocID property. If the property is set, replace the text of this element with the resource text specified in ValueLocID. So basically the idea is this:

  • Load the RDLC file into memory as an XML file
  • Pass the XML file with XPath, looking for the ValueLocID properties.
  • Replace the innerText of this XML node with the resource specified in ValueLocID
  • Download the ReportViewer control using a copy of the memory of the RDLC file.

See the function below that will do what I mentioned above.

Private Sub LocalizeReport() Dim xmlDoc As XmlDocument = New XmlDocument Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly() 'create in memory, a XML file from a embedded resource Dim xmlStream As Stream = asm.GetManifestResourceStream(ReportViewer1.LocalReport.ReportEmbeddedResource) Try 'Load the RDLC file into a XML doc xmlDoc.Load(xmlStream) Catch e As Exception 'HANDLE YOUR ERROR HERE End Try 'Create an XmlNamespaceManager to resolve the default namespace Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable) nsmgr.AddNamespace("nm", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition") nsmgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner") 'IMPORTANT LINE BELOW 'YOU WILL NEED TO SET THIS TO YOUR RESOURCE MANAGER, OTHERWISE NOTHING WILL WORK Dim rm As ResourceManager = New ResourceManager("Insurance.Subs.WinUI.Controls.Resources", asm) 'Loop through each node in the XML file, that has the ValueLOCId property set. 'Using this property as a workaround for localization support. The value specified in this 'property will determine what resource to use for translation. Dim node As XmlNode For Each node In xmlDoc.DocumentElement.SelectNodes(String.Format("//nm:{0}[@rd:LocID]", "Value"), nsmgr) 'XPath to LocID Dim nodeValue As String = node.InnerText If (String.IsNullOrEmpty(nodeValue) Or Not nodeValue.StartsWith("=")) Then Try Dim localizedValue As String = node.Attributes("rd:LocID").Value 'Get the resource via string localizedValue = rm.GetString(localizedValue) If Not String.IsNullOrEmpty(localizedValue) Then 'Set the text value - via the retrieved information from resource file node.InnerText = localizedValue End If Catch ex As Exception 'handle error End Try End If Next ReportViewer1.LocalReport.ReportPath = String.Empty ReportViewer1.LocalReport.ReportEmbeddedResource = Nothing 'Load the updated RDLC document into LocalReport object. Dim rdlcOutputStream As StringReader = New StringReader(xmlDoc.DocumentElement.OuterXml) Using rdlcOutputStream ReportViewer1.LocalReport.LoadReportDefinition(rdlcOutputStream) End Using End Sub 
+2
source share

I agree with Igoy on this by recently skipping the steps listed in codeperot, but would like to add that the steps you need to take when adding a new CodeGroup are slightly behind in that if you put the new CodeGroup anywhere, after the unnamed UnioncodeGroup (it matches Url = "$ CodeGen $ / *") your attempts to access your custom assembly will fail.

After a lot of digging, I was able to find confirmation of this on one of the msdn pages (see the "Placing Group Policy Elements for Extensions" section). Their wording was that it is "recommended", but from my testing I would say that this is necessary, at least when directly testing on the report server: http://msdn.microsoft.com/en-us/library/ ms152828.aspx

The xpath for this location in the .config files is the same (useful on wix): // PolicyLevel / CodeGroup / CodeGroup [[] @ class = 'FirstMatchCodeGroup' []] / CodeGroup [[] @PermissionSetName = 'ReportLocalization' []]

0
source share

Going to the dataset SQL dsTranslations path (I don't like it in XML)

This allows you to make a simple interface so that your customers complete the translations, for example, the lightswitch quick GUI

enter image description here

Using this dataset, I do a simple search for translation

 =Lookup("WORDTOBETRANSLATED", Fields!Key.Value, Fields!Value.Value, "dsTranslation") 

This second method is the one that I personally use, in case the key is not in dbTranslations, it shows the wat key that they should add to db. I could probably make this second part more elegant, feedback is welcome.

 =Microsoft.VisualBasic.Interaction.iif(Lookup("WORDTOBETRANSLATED", Fields!Key.Value, Fields!Value.Value, "dsTranslation") = "", "WORDTOBETRANSLATED", Lookup("WORDTOBETRANSLATED", Fields!Key.Value, Fields!Value.Value, "dsTranslation")) 
0
source share

An easy way to do a multilingual ssrs report is to hardcode or use sharedataset. however, we will run into a rendering performance issue if we use a share dataset.

Here is an efficient approach to translating labels in a report with better performance (especially when rendering performance)

Step 1: Deploy the library to support obtaining the dictionary for reports, the example below is for reference, this must be changed to return the correct dictionary

 using System; using System.Collections.Generic; using System.Configuration; using System.Data.SqlClient; using System.Linq; using System.Security.Permissions; using System.Text; using System.Data.SqlClient; namespace CmsReportLibrary { public class DictionaryLabel { DictionaryLabel() { } public static string[] GetDictionary(int languageid) { System.Data.SqlClient.SqlClientPermission oPerm = new System.Data.SqlClient.SqlClientPermission(PermissionState.Unrestricted); oPerm.Assert(); SqlConnection oConn = new SqlConnection(); oConn.ConnectionString = ConfigurationManager.ConnectionStrings["appconnectionstring"].ConnectionString; //oConn.ConnectionString = "Data Source=(local);Initial Catalog=Northwind;User Id=<>;Password=<>"; //oConn.Open(); //SqlCommand oCmd = new SqlCommand(); //oCmd.Connection = oConn; //oCmd.CommandText = ".................."; // .................... //oConn.Close(); return new string[] {...............}; //ex return new string[] { "Client||Klient", "Week||Woche", "Year||Jahr"}; } } } 

Step 2: Compile the library and copy it to the Bin folder in the ReportServer Reporting Service

For example: copy the library to C: \ Program Files \ Microsoft SQL Server \ MSRS10_50.R2 \ Reporting Services \ ReportServer \ bin

Step 3: Modify the rssrvpolicy.config file in the ReportServer folder (for example: C: \ Program Files \ Microsoft SQL Server \ MSRS10_50.R2 \ Reporting Services \ rssrvpolicy.config >), find "$ CodeGen $" and add the following code to inform SSRS of the location of the new library

 <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="CoDeMagSample" Description="CoDe Magazine Sample. "> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.R2\Reporting Services\ReportServer\bin\CmsReportLibrary.dll" /> </CodeGroup> 

Step 4: Stop and start Reporting Services in Reporting Services Configuration Manager

Step 5: Apply the library to the SSRS report Create a new report or modify a new report, this report must have the languageid parameter Set library links for this report Right-click the report, select "Report Properties" Go to the "Links" tab Insert the library links in Add or remove assemblies area:

 CmsReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 

enter image description here

Step 6: add custom code to support label wrapping

 public Shared Dim ListLabel as String() 

GetListLabel function (language as a whole) ListLabel = CmsReportLibrary.DictionaryLabel.GetDictionary (Parameters! LanguageId.Value) final function Translate (input as String) function as a string

 dim i as Integer For i=0 to UBound(ListLabel,1) if Instr(ListLabel(i), input) > 0 then Translate = Replace(ListLabel(i), input + "||","") exit function end if Next 'Not found, return any string you want Translate = "not found" end function 

Step 7: add a new report variable enter image description here

Expression for ListLabel Variable

 =Code.GetListLabel(Parameters!LanguageId.Value) 

Step 8: Translate Labels To Report

Change the label expression, use the translation method in user code to translate

For example:

 =Code.Translate("Client") =Code.Translate("Week") 
0
source share

All Articles