Jasper Report Localization Example
Applying localization on jasper reports and jasper input controls. This blog post helps you understand how localization can be achieved , what can be localized and its limitations.
What can be localized?
Localization can be done on data which is static in nature i.e data which is not coming from database. Below are the few items where it can be achieved.
- Input controls.
- Report title.
- Legends.
How to localize reports?
Create a property file and enter input control name – value pairs, report title name.. etc. This is a one time activity and this file to be saved with extension .properties. EX: “file_name.properties”
Before creating property file, I recommend users to analyze what all can be localized on jasper report like input control names and its value, report title, legends, table component headers etc.
Step 1: Create property file as I shown below for both English and Spanish.
Step 2: Edit your Input Control and modify the value of [“Prompt Text” / Name of Input Control] to “$R{inputcontrol_id}”.
Step 3: Remove all the name and values from Edit List of values and modify as I shown in below picture.
Step 4: Update your JRXML by providing Resource Bundle. Resource Bundle is nothing but the file name of your property file which is created at Step-1 and is a property of report and publish your report.
Where and How to upload properties file in Jasperserver?
Property file can be upload in 2 ways. One way from iReport and other way via JasperServer. I prefer to upload property file from JasperServer rather from iReport. Please follow my steps.
Step 1: Edit your report and navigate to “Controls & Resources” tab and click on “Add Resource”.
Step 2: Browse property file and navigates to next page where you need to give Resource Name and Resource ID.
NOTE: Resource Name and Resource ID both should match with the file name of your properties. Please find the screen shot.
By this time you might have get a doubt how spanish language can be achieved. No worries the solution is very simple. For spanish you need to save your filename as “localization_es.properties” and then upload the same file in Jasperserver. Please follow my screen shot.
Remember: Each time when you update your property file, it has to be uploaded to server.
Localization Limitations:
– Localization cannot be achieved on Input controls for type
- Single select query
- Multi select query
- Single select query (Radio)
- Multi select query (Radio)
– Localization cannot be done on the data which is dynamic in nature.
Best Open Source Business Intelligence Software Helical Insight is Here
Hi ,
I have few question regarding localisation.
Ques 1: Why it is not possible to localize dynamic data, there should be some way to achieve that ?
Ques 2 : If data inside the tables need to localize, then what should be the approach ?
It would be really helpful if you could answer me on my mail id
mail id : vipul.mandpe@gmail.com