Localisation in Sub Report


I'm trying to create a report with multiple subreports contained within it that is localised. I've passed the REPORT_RESOURCE_BUNDLE and the REPORT_LOCALE to JasperFillManager using the hash map of parameters. 

The translations are working on the master report, however all sub reports are still in english, despite passing the master reports parameters to them via the parameterMapExpression. I have also confirmed the correct parameters (resource bundle and locale) have been passed to the sub report by printing them onto the sub report. 

The properties files are named in the convention:
messages_es.properties, messages_fr.properties etc..

I'm creating the hashmap as follows:

final ResourceBundle resourceBundle = ResourceBundle.getBundle("org.example.messages", new Utf8Control());
parameters.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle);
parameters.put(JRParameter.REPORT_LOCALE, printParameters.getLocale());
final JasperPrint jasperPrint = JasperFillManager.fillReport(layoutJasperReport, parameters, jasperDataSource);

Then in the master report, I'm passing the parameters to the sub report like this:


Finally, in the sub report i'm trying to get a localised property by using:


Could anyone offer some insight into why this could be happening?

lappera's picture
Joined: Feb 21 2019 - 4:16am
Last seen: 4 years 7 months ago

0 Answers:

No answers yet