This is a migrated thread and some comments may be shown as answers.

Localization from code behind

2 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 19 Feb 2013, 12:00 AM
Hi all,

I have a report localized in many languages and it works well when I request the contents from a report viewer and I set the threat to match the report's localized language.

Now, I would like to download the report without having to change the current threat or using the report viewer. The code below generates the PDF file directly and presents the document ready for download to the browser, this is what I would like to have but I cannot get it translated. I was trying to use the report parameters with the report's code behind to set the language in the report but unfortunately the report must be initialized before I can work with the parameters.
Is that possible?

The code looks like this:
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = New Reporting_Service.doc_PO_ShippingInstructions
instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("Id", 31))
instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("LanguageID", 1))
 
Dim reportProcessor As New ReportProcessor()
Dim result As RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, Nothing)
Dim fileName As String = result.DocumentName + ".pdf"
Response.Clear()
Response.ContentType = result.MimeType
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Expires = -1
Response.Buffer = True
Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName))
Response.BinaryWrite(result.DocumentBytes)
Response.End()

2 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 1
answered on 28 Feb 2013, 03:36 PM
bump! Anybody?
0
IvanY
Telerik team
answered on 05 Mar 2013, 12:15 PM
Hi Marc,

What you can do is to change the current thread culture only for the export and then return it to the original state. Just store the initial culture info, export the report and use the stored values to revert the culture.

Other than that you can use a report parameter for the localization but that is only if your database for example (or your data source in general) supports multiple languages. If you are relying on resx files the only option is to change the culture. For more information about resx files and localization please check the ASP.NET Globalization and Localization article.

All the best,
IvanY
the Telerik team

See what's new in Telerik Reporting Q1 2013. Register for the March 4 webinar to witness the impressive new visualizations in Telerik Reporting. Just for fun, 10 webinar attendees will be randomly selected to win a Telerik T-shirt and a $50 Gift Certificate to ThinkGeek. Register now! Seats are limited!

Tags
General Discussions
Asked by
Marc
Top achievements
Rank 1
Answers by
Marc
Top achievements
Rank 1
IvanY
Telerik team
Share this question
or