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

Problem with default locale in JasperReports


clandestino

Recommended Posts

I am using jasperreports to display reports in croatian (default language of application) and english.

I have 2 properties files: messages.properties and messages_en_US.properties. My messages.properties file contains croatian words, and messages_en_US.properties contains english words. The thing is wheater I set croatian locale or no local at all, jasper reads text from my messages_en_US.properties file, and not the default one messages.properties. Only if I explicitly rename messages.properties to messages_hr_HR.properties the code down works fine and jasper generates croatian text.

 

Locale locale = new Locale("hr","HR");
params.put(JRParameter.REPORT_LOCALE, locale);

What can I do so the jasper reads the deafult messages.properties (croatian) file instead messages_en_US.properties, but so that I don't need to rename messages.properties to messages_hr_HR.properties?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 weeks later...

kingananth007
Wrote:

cant digest the way you fixed that...also there is a standard in naming convention try to adhere to it.

Take a look at ResourceBundle.getBundle, which JR uses to load report resource bundles.  Note that the resource bundle which corresponds to the default JVM locale is preferred over the base resource bundle, so if your default locale is en_US, messages_en_US.properties is going to be used and not messages.properties.

If the default JR mechanism doesn't work as you expect, you can load a java.util.ResourceBunle instance yourself and pass it to the report via the JRParameter.REPORT_RESOURCE_BUNDLE parameter.

HTH,

Lucian

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