Monday 30 September 2013

localization of jasper reports OR Internationalization of jasper reports - Hello world example

Hi.. small work out but very use full..
Generally customers want to see data in their own language.

This example is developed using iReport 5.1.0 pro, Jasper server pro and foodmart db with postgresql.

Sources/References :
Example : Converting English to Spanish
1) From Jasper Community
 https://www.jaspersoft.com/jasperserver-and-ireport-internationalization#int_reports

2) From google translator
http://translate.google.co.in/#auto/pt/BRAZILIAN%20STATE%20X%20SIGN%20UPS

 
 3) Locale Codes 
 http://download1.parallels.com/Plesk/Plesk8.2/Doc/plesk-8.2-win-l10n-guide/39382.htm
4) Tutorial Point
http://www.tutorialspoint.com/jasper_reports/jasper_Internationalization.htm

Steps:
1) File->New ->Save report with your fav name to your fav directory.
2) Write a simple query and drag a field to title band( Not necessary to do but iReport requires some query and field otherwise it'll show empty report).
3)Take Text field(Not static text) and write the following.
$R{localization.text1}
NOTE: $R is the special syntax used for internationalization of text in iReport.
4) Right click on report Name -> Select properties -> Give Resource bundle Name
Ex: localizationdemo
This is resource bundle name

5) Publish your report to Jasper Server and in resources section add the bundle files.
 You need to add two files..
One file contains general English text(USA) another consists internationalized text
In this example second file having spanish(B'z you are converting English to spanish)

Right click on Resources -> Add -> Resource Bundle  id ,Name and browse for the files
You must add two files.
Example:
File 1 ID & Name : localizationdemo.properties  (You can give any of your name , extension is not mandatory). Write this text in file

localization.text1=hello world
File2 ID & Name : localizationdemo_es.properties and add the file from your local machine. Write this text in file
localization.text1=hola mundo


In jasper server Change locale to es-Spanish

See the preview of the report.
Sample output


 

Sadakar
BI developer


1 comment:

  1. .properties files localization can be managed online with the translation platform https://poeditor.com
    You should give it a go, I think you'll find it useful.

    ReplyDelete