# Using the new locale parameter in Jasper Report Plugin

**URL:** <https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939>\
**Category:** Classic Servoy\
**Created:** [November 27, 2008, 1:39pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939 "2008-11-27T13:39:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [November 27, 2008, 1:39pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/1 "2008-11-27T13:39:58Z")

</div>

Hello,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![Thomas\_Parry](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Thomas\_Parry](https://forum.servoy.com/u/Thomas_Parry)\
**Post date:** [November 27, 2008, 4:00pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/2 "2008-11-27T16:00:54Z")

</div>

Hi Martin,  
For Locale see: [JDK 23 Documentation - Home](http://java.sun.com/j2se/1.4.2/docs/api/java/util/Locale.html)  
from this description I see that one has to create a new Locale object:

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

```

then your argument needs the toString method:

```auto
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

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 12, 2009, 11:13am UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/3 "2009-01-12T11:13:50Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [January 12, 2009, 12:01pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/4 "2009-01-12T12:01:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 12, 2009, 12:18pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/5 "2009-01-12T12:18:48Z")

</div>

Hi Paul,

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

```auto
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](https://canada1.discourse-cdn.com/flex010/uploads/servoy/optimized/2X/f/f3b2ba1a3f9f2c5a26d15a0b2e5203190f416882_2_690x32.jpeg)

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [January 12, 2009, 1:03pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/6 "2009-01-12T13:03:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 12, 2009, 5:04pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/7 "2009-01-12T17:04:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jbader](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jbader](https://forum.servoy.com/u/jbader)\
**Post date:** [February 3, 2009, 3:48pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/8 "2009-02-03T15:48:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [February 3, 2009, 4:06pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/9 "2009-02-03T16:06:51Z")

</div>

In Jasper you should use $R{MyKeyName}

---

<div class="post-metadata">

**Author:** ![jbader](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jbader](https://forum.servoy.com/u/jbader)\
**Post date:** [February 3, 2009, 4:18pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/10 "2009-02-03T16:18:07Z")

</div>

OK, so not $R{i18n:MyKeyName}

right?

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [February 3, 2009, 4:48pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/11 "2009-02-03T16:48:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jbader](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jbader](https://forum.servoy.com/u/jbader)\
**Post date:** [February 3, 2009, 4:59pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/12 "2009-02-03T16:59:06Z")

</div>

Thx Paul!

---

<div class="post-metadata">

**Author:** ![jbader](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jbader](https://forum.servoy.com/u/jbader)\
**Post date:** [February 5, 2009, 5:45pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/13 "2009-02-05T17:45:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tokajac](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tokajac](https://forum.servoy.com/u/Tokajac)\
**Post date:** [September 23, 2011, 5:38pm UTC](https://forum.servoy.com/t/using-the-new-locale-parameter-in-jasper-report-plugin/9939/14 "2011-09-23T17:38:42Z")

</div>

Useful tips -thanks

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

```auto
<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](https://www.servoyforge.net/projects/servoy-jasperreports/files)

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

Regards
