Using the new locale parameter in Jasper Report Plugin

Hello,

Is there someone who has already used the new Locale parameter with the Jasper Report Plugin?

plugins.jasperPluginRMI.jasperReport(currentcontroller.getServerName(),'test.jasper',true,'viewer',null, '_nl_BE');

The last new parameter is used to set the Locale in the Jasper Report.
When using _nl_BE in Jasper as the Locale we get the correct translated value.
But when using the Jasper Plugin we do not succeed.

What is the exact syntax for Locale?

Maybe there should even be a method that returns this value:

application.getLocale() or i18n.getLocale() or Plugins.jasperPluginRMI.getLocale()

Anyone that already has used this parameter?

I’ll be glad to hear.

Martin

Hi Martin,
For Locale see: JDK 23 Documentation - Home
from this description I see that one has to create a new Locale object:

var myLocale = new java.util.Locale('nl');//using the ISO 3166 language code

then your argument needs the toString method:

var myLocaleString = myLocal.toString();

then use this to pass in to the plugin.

Of course the plugin will do exactly the reverse operation in order to get at the Locale object - but this might be a way to check it works.
I have not tried this but this seems to be the way to test.
Tom

Is there anyone who already has used i18n in combination with the Servoy Jasper Reports Plugin?

I’m using the latest version of the Plugin (2.1.3)

The coding that I use is the following:

var param = new java.util.HashMap();
param.put('sales_invoice_id', '6a27a1a7-c9ce-4bce-9925-ba151df5a20d');


var myLocale = new java.util.Locale('nl', 'BE');//using the ISO 3166 language code
var myLocaleString = myLocale.toString();
var _result = plugins.jasperPluginRMI.jasperReport('havelaar_online', 'webshop_havelaar_invoice.jrxml', null, 'viewer', param, myLocaleString);

return true;

The I18N labels are not shown.
When using I18N within iReports then correct labels are shown.

I tested with both Servoy 3.5.7 and Servoy 4.1, but that doesn’t make any difference as well.

As per the sample docs: you need to specify a String, like ‘nl’, ‘es’ etc.

The translation of the i18n keys ought to work out of the box.

You say the labels are not shown. Meaning what exactly? The String is empty?

Any errors in the log?

Paul

Hi Paul,

Even with string ‘nl’ or ‘nl_BE’ as last parameter, it is not working.

var _result = plugins.jasperPluginRMI.jasperReport('havelaar_online', 'webshop_havelaar_invoice.jasper', null, 'viewer', param, 'nl_BE');

The i18n-key is shown in the report, not the value (see screenshot)
Of course the i18n-properties file is in the directory where the reports are located (filename is ‘webshop_havelaar_invoice_nl_BE.properties’)

By the way, should we use the .jasper or the .jrxml extension when calling the plugin?

Martin

Capture.JPG

You don’t need to supply a i18n properties file. The plugin feed the i18n keys of the client to the report engine.

So, the i18n keys you use in your report need to be located in the i18n table in Servoy that your solution uses.

Paul

Thanks for the reply Paul

We didn’t know that the I18N table was used/could be used.

We succeeded to use I18N in Jasper Report now

Martin

Hello, for the sake of clarity should the i18n prefix be used or just the key?

Meaning should I reference:

i18n:MyKeyName

or just

MyKeyName

in Jasper

Thx

In Jasper you should use $R{MyKeyName}

OK, so not $R{i18n:MyKeyName}

right?

the i18n: prefix is only relevant inside Servoy, to distinquishe a normal text string from an i18n key.

Inside Jasper you already specify that you want i18n by using the notation $R{}, so a prefix is not needed.

Paul

Thx Paul!

Also, just an FYI you have to use a field component, not a static text component (within jasper).

Useful tips -thanks

New question:
How to use $R{MyKeyName} in SUBreports? I’ve tried with

<subreportParameter name="REPORT_RESOURCE_BUNDLE">
<subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression>
</subreportParameter>

but I get null? What else needs to be done? I use Basic_Servoy_JasperReports_Plugin_v.3.2.0.zip from
https://www.servoyforge.net/projects/se … orts/files

Found same issue:
https://www.servoyforge.net/issues/347#change-798

Regards