Jump to content
We've recently updated our Privacy Statement, available here ×

Static Text Dependant on Language


croutledge

Recommended Posts

In our Web Application we are using a table to hold text used in our JSP pages (column headings, output boxes, etc) for each page and a language.

For example

code, displayText, language, group

welcome, Welcome, en_GB, UIWelcomePage

Now on each Form we pull the full the entire list for the current page and language and use them.  Will i be able to do something similar in a report?

I need to be able to call a java operation passing the code, group and language and then use the correct display text.  But if i do this for each label then it could be consuming.  Or would it be easier to pass a list (Map) to the report and use it that way.

A lot of our reports will be ran from Java code and supplied with either a db connection or a JRBeanCollectionDataSource dependant on how we created the report in the first place.

Any suggestions?

 

Cheers

Carl



Post Edited by croutledge at 05/08/2009 05:54
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

It's up to you. First of all you have to replace your static labels with textfields to be able to use a java expression to define the text, then you can implement your localization mechanism (a map sounds rasonable) or use what JasperReports already provides for internationalization (your should just pass as parameter the Locale to use and provide the correct resource bundle).

Giulio 

Link to comment
Share on other sites

Given your report is called “MyReport”, create a resource file “MyReport.properties” (or “MyReport_en.properties”, “MyReport_de.properties”, … ) .

Within the properties file define then whatever you want to internationalize, e.g. “reportName=Mein Bericht”. Define the ‘resource bundle’ property (“<pathtoyourresourcedir>.MyReport”) in iR and use your localized value for your text field expr. like this “$R{reportName}”.

Maybe you’ll have to add the resources path under options | classpath.

 

HTH,

dman

 



Post Edited by dman at 05/12/2009 09:14
Link to comment
Share on other sites

Thanks for the reply dman.

This is one option i can look into. We did one of our original J2EE projects with property files but felt it was limited in that a whole project would need to be released to add a new set of language data. So in our latest J2EE project we have used a db table to drive this and just look the information up from there. So because we have a lot of data already in a table that we could use in a report i would like to do just that.

 

Cheers

 

Carl

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...