Set Report Culture With Variable Expression

Stimulsoft Reports.PHP discussion
Post Reply
servitux
Posts: 9
Joined: Thu Feb 29, 2024 3:29 pm

Set Report Culture With Variable Expression

Post by servitux »

Hi.

I have a report, with a variable named CULTURE, with value "es-ES". The expression used in Report Culture Property is {CULTURE}

In Stimulsoft Designer, report renders fine. If we change CULTURE value to "en-US", reports shows english translations on preview. That's fine.

But, when I launch the report from PHP, and I set the CULTURE value to "en-US" in onPrepareVariables event, variable is set with value "en-US" successfully (we show value in report detail and it shows "en-US"), but report not render in English. We try with AutoLocalizeReportOnRun set to true and to false, with the same result.

What's is wrong?

Thanks.

Image
Image
Image
Image
Max Shamanov
Posts: 792
Joined: Tue Sep 07, 2021 10:11 am

Re: Set Report Culture With Variable Expression

Post by Max Shamanov »

Hello,

Please send us a sample report with test data that reproduces the issue.

Thank you.
servitux
Posts: 9
Joined: Thu Feb 29, 2024 3:29 pm

Re: Set Report Culture With Variable Expression

Post by servitux »

Hi, thanks for your faster awnser.

Problem exists with sample report with json datasource and 3 columns with 3 rows, and with a complex report with headers, 3 datasources, etc... the problem is not the report, I think... Designer is working, but not the Viewer from PHP.

JS report object needs a method or property set to another value to do the translation before the render?

Thanks
servitux
Posts: 9
Joined: Thu Feb 29, 2024 3:29 pm

Re: Set Report Culture With Variable Expression

Post by servitux »

More info: I'm using Laravel 10. Do the report viewer needs a special route or ignore crsf token?
servitux
Posts: 9
Joined: Thu Feb 29, 2024 3:29 pm

Re: Set Report Culture With Variable Expression

Post by servitux »

Hi again.

I have been doing some tests, and I have solved it as follows:

In PHP:
onPrepareVariables event, I fill {CULTURE} variable, but this value does not make it to the report, or does not take it into account, although it is shown in the detail section (????)


In <script> section on viewer:

Code: Select all

<script type="text/javascript">
    <?php
      $handler->renderHtml();
    ?>

    function onBeforeRender(event)
    {
      var variable = event.report.dictionary.variables.getByName('CULTURE')
      console.debug(variable.value); //CULTURE IS NOT SET YET! ???
      if (variable) variable.value = "{{$culture}}";
      console.debug(variable.value); //CULTURE IS NOW SET AND REPORTS RENDERS SUCCESSFULLY
    }

    function onLoad() {
      <?php
        $viewer->renderHtml('viewerContent');
      ?>
    }
</script>
In this JS block, CULTURE variable not yet have the value of the established culture on PHP onPrepareValues event (???), but if we fill the value now, then it works.

Could be a bug in the onPrepareVariables event???

Thanks
Max Shamanov
Posts: 792
Joined: Tue Sep 07, 2021 10:11 am

Re: Set Report Culture With Variable Expression

Post by Max Shamanov »

Hello,

Thank you for the imformation.
We need some time to investigate the issue. We will let you know about the result.

Thank you.
Post Reply