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

Report Localization / Globalization Problem

11 Answers 699 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
renemt
Top achievements
Rank 2
renemt asked on 31 Mar 2009, 09:13 AM
Hi there!

I'm using Telerik Reporting Q1 2009 in a CAB WinForms application (along with RadControls for WinForms) under Windows Vista. I need to provide a globalized version of some reports where the user can chose the language of a report from the application's UI.

As proposed in the documentation I designed the report in the default language (here: German). After this I set the Localizable property of the report to True in the report designer, changed the Language property of the report to the desired language (here: English (US)) and localized all strings used in the report form. After saving, I got two resource files as expected, one for the default language (MyReport.resx), one for the localized version (MyReport.en-US.resx), both containing the correctly localized string resources. Compiling the project also results to a proper satellite assembly for the localized culture, residing in a subfolder named by the culture:

.\MyReport.dll
.\en-US\MyReport.resources.dll


These file/folder structure is also copied to the application's bin folder, along with all other depedent assemblies etc.

As far as I see this is all correct behavior until here.

In the application I use the following code to set the report's Culture property to the desired one, lets say English US):

Report report = new MyReport(); 
report.Culture = new CultureInfo("en-US"); 
report.DataSource = someDataSet; 

The report will get rendered in another place, once as PDF and once by the WinForms ReportViewer:

string mimeType = ""
string extension = ""
Encoding encoding = null
 
Hashtable deviceSettings = new Hashtable(); 
deviceSettings["FontEmbedding"] = "Subset"
deviceSettings["DocumentTitle"] = report.DocumentName; 
deviceSettings["DocumentAuthor"] = "My Company"
 
byte[] buffer =  
    Telerik.Reporting.Processing.ReportProcessor.Render("PDF", report, deviceSettings, out mimeType, out extension, out encoding); 
 
// ... save the PDF using FileStream ... 
 

// WinForms initialization code 
private Telerik.ReportViewer.WinForms.ReportViewer mainReportViewer; 
 
// .... 
 
public void ShowReport(Report report) 
    mainReportViewer.Report = report; 
    mainReportViewer.RefreshReport(); 
 
 

As you see this code is also no rocket sience.

My Problem is that the report always keeps it's default language and will never show in English (US) as desired, regardless of the above mentioned conditions (report localized, got satellite assemblies in the right place [assumedly], report's Culture property explicitly set). I also set the current thread's CurrentUICulture property to english, as well as the whole operating system's default language - but the report still stays "unlocalized". So the problem seems to be that for some reason the satellite assembly won't get used for localization.

Does anyone has a helpful hint what the problem could be here?

Regards,
ReneMT






11 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 03 Apr 2009, 12:39 PM
Hi renemt,

We've tested this on our end and did not encounter any problems. Where do you set the CurrentCulture and CurrentUICulture properties? Please set the following in the form's constructor just before InitializeComponent() i.e.

public Form1()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            InitializeComponent();
        }

and verify if that makes a difference. If still having problems it would be best if you send us a sample project that replicates the issue.

Regards,
Steve
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Behzad
Top achievements
Rank 1
answered on 13 May 2015, 01:47 PM

I am also having the same issue,

 I am trying to render the report in Chinese language. The report also have appropriate .resx file for that but when render the report to pdf it is still in English.

<p> var reportProcessor = new ReportProcessor();<br> <br>            // set any deviceInfo settings if necessary<br>            var deviceInfo = new Hashtable();<br> <br>            var reportSource = new InstanceReportSource {ReportDocument = report};</p><p>return reportProcessor.RenderReport("PDF", reportSource, deviceInfo);</p>

0
Stef
Telerik team
answered on 15 May 2015, 09:51 AM
Hi Mayank,

Please check the current thread's culture before rendering the report, in order to verify the correct culture is set. More details are available in Localizing Reports.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Behzad
Top achievements
Rank 1
answered on 15 May 2015, 01:27 PM

Hi,

 Current thread's culture is correct as well, it is set to "zh-CHS" but still the reports are rendered in English only.

0
Behzad
Top achievements
Rank 1
answered on 15 May 2015, 02:26 PM
Got it working. But another issue, in pdf format the text is shown as boxes. Actual Chinese text is not showing. Working fine for RTF and PPT and Excel
0
Stef
Telerik team
answered on 15 May 2015, 02:31 PM
Hi Mayank,

Please check the Design Considerations for PDF Rendering (Font Requirements) article and verify you are using a TrueType Unicode font like Arial Unicode MS. The font must be installed on the server where reports are processed and rendered.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
radhika
Top achievements
Rank 1
answered on 20 Jan 2016, 07:00 AM

Hello,

I am also having the same issue,
I am trying to render the report in Arabic language. The report also have appropriate .resx file for that but when I render the report it is still in English.Text switching is properly done in design time but in run time It still gets displayed in English text only.

How do I resolve this issue?

 

0
radhika
Top achievements
Rank 1
answered on 20 Jan 2016, 11:20 AM

Hello, 

public Form1()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");  //get input string from report parameters
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            InitializeComponent();
        }

this approach works properly, but only if we write set CutureCode before InitializeComponent(); Not after it. Is there Any alternative possible for that?

Also How do it get Report Parameters directly in construtor for achieving this kind of approach ->

"System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");  //get input string from report parameters i.e parameters["CultureInfoCode"].value"

 

0
Stef
Telerik team
answered on 21 Jan 2016, 05:43 PM
Hi Radhika,

Please check my previous posts. Reports designed in VS can be localized via RESX files, where the culture must be set before initializing the components in order to create resource manager with the correct culture - Localizing Reports.

Also the fonts used in reports must have support for the used Unicode symbols - Design Considerations for PDF Rendering (Font Requirements).

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
radhika
Top achievements
Rank 1
answered on 22 Jan 2016, 05:56 AM

Hi Stef,

Reports localization works properly But my question is how do I get Report Parameters directly in construtor for achieving this kind of approach ->

public Form1()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");  //get input string from report parameters i.e parameters["CultureInfoCode"].value"
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); //get input string from report parameters i.e parameters["CultureInfoCode"].value"
            InitializeComponent();
        }

0
Stef
Telerik team
answered on 22 Jan 2016, 03:28 PM
Hi Radhika,

Report parameters are part of the report definition and cannot be used before the InitializeComponent method. The parameters values are evaluated once the data processing is started - in events. At this point it is too late to read the culture from a report parameter, because the resource manager is created first
before creating other items in the report.
The thread's culture must be set before initializing the report.

If you want to create custom localization based on report parameters, you will need custom user functions getting the localized strings. The custom functions can be used in expressions to visualize text in the report.

For more details, please check Localizing Reports.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
renemt
Top achievements
Rank 2
Answers by
Steve
Telerik team
Behzad
Top achievements
Rank 1
Stef
Telerik team
radhika
Top achievements
Rank 1
Share this question
or