Resource bundle configuration in Jasper Reports

There might be the need to show up the locale-specific information on your website. If the selected language is Russian, the concerned PDF must get generated in Russian, so on and so forth. I have seen people fumbling on how to get the resource bundle configured, to achieve this functionality.

Before we move ahead, make sure you have the respective unicode font JARs in your build path. For any clarifications, click here.

Hopefully, you might be having the similar implementation as below:

This is all you need to do on the Java side, to set the REPORT_RESOURCE_BUNDLE parameter before exporting the report.


In the JRXML PDF template, you need to modify as:

The resource bundle entries are accessed with $R as shown above, and must have the corresponding entry in the messages_en_US.properties and messages_ru_RU.properties file at the appropriate directory location as:

messages_en_US.properties

name=Name

messages_ru_RU.properties

name=название

Note that, StringUtility that I have used above, is my custom utility class that I have created to unescape the resource bundle values so that when the PDF gets rendered, I get the correct Russian characters displayed and not the escaped characters.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.