Report Localization / Globalization Problem

12 posts, 0 answers
  1. renemt
    renemt avatar
    40 posts
    Member since:
    Jul 2007

    Posted 31 Mar 2009 Link to this post

    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






  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 03 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. Mayank Aggarwal
    Mayank Aggarwal avatar
    3 posts
    Member since:
    Mar 2010

    Posted 13 May 2015 in reply to Steve Link to this post

    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>

  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 15 May 2015 Link to this post

    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
  6. Mayank Aggarwal
    Mayank Aggarwal avatar
    3 posts
    Member since:
    Mar 2010

    Posted 15 May 2015 in reply to Stef Link to this post

    Hi,

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

  7. Mayank Aggarwal
    Mayank Aggarwal avatar
    3 posts
    Member since:
    Mar 2010

    Posted 15 May 2015 Link to this post

    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
  8. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 15 May 2015 Link to this post

    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
  9. radhika
    radhika avatar
    7 posts
    Member since:
    Dec 2015

    Posted 20 Jan in reply to Stef Link to this post

    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?

     

  10. radhika
    radhika avatar
    7 posts
    Member since:
    Dec 2015

    Posted 20 Jan in reply to radhika Link to this post

    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"

     

  11. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 21 Jan Link to this post

    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
  12. radhika
    radhika avatar
    7 posts
    Member since:
    Dec 2015

    Posted 21 Jan Link to this post

    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();
            }

  13. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 22 Jan Link to this post

    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
Back to Top
DevCraft banner