Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Rendering reports in multiple locales and localized properties
djatnieks
I am having a problem when trying to render a report in multiple locale's. What I am doing is like this (Java psuedocode):
// Run the report
runtask = engine.createRunTask(...);
runtask.run (myReportDoc);
reportDoc = engine.openReportDocument(myReportDoc);
rendertask = engine.createRenderTask(reportDoc);
for each locale {
rendertask.setLocale( locale );
rendertask.render();
}
For each locale I have a localized properties file. e.g
myReport_en.properties
myReport_fr.properties
...
The problem I am having is that once the first locale is set and Birt selects the appropriate properties file - myReport_fr.properties for example - then subsequent setLocale() calls seem to change _only_ the locale settings and _not_ the properties file. E.g. All my reports are rendered using the French properties file, but date/number formatting are correctly using each locale.
So with "en" and "fr" as my locale's and if French is the first locale, both my reports are rendered in French, but the French version has French date/number formatting and my English report is also in French with U.S. date/number formatting.
How can I fix this? Is this a bug?
Find more posts tagged with
Comments
mwilliams
Hi djatnieks,
What version of BIRT are you using?
djatnieks
This is Birt 2.3.1
mwilliams
djatnieks,<br />
<br />
Have you tried creating a new rendertask for each locale? Not sure that that's the correct answer, but it's worth a shot. It doesn't seem like it'd be as efficient as just changing the locale, but it may work. If I find out more info on this issue, I'll post in here. If it does work by creating a new rendertask, it may be worth reporting a bug on this anyways as that would not be the most efficient way to go about things. You can report bugs here:<br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/reportabug.php'>BIRT
: Reporting Bugs and Requesting Enhancements</a>
mwilliams
djatnieks,
More info: Make sure that when you create the new rendertask for each loop that you use the setLocale for each one. Also, make sure to close the open task each time. Let me know if this works.
Please go ahead and log a bug for this at the link I posted above and post any bug info in here for future reference, if you would. Thanks.
djatnieks
Hi Michael,
Thanks for the suggestion - I tried getting a new rendertask each time, setting the locale, calling render() followed by close(), but I still get the localized text from the first locale in all my html.
This is strange, as I am not setting a locale except for the render task, so I thought it would work too; it must be getting set in a static variable somewhere.
BTW, I am using a modified version of ReportRunner, so it should be easy to reproduce.
If you have any other ideas, let me know!
Thanks,
dan.
djatnieks
I opened a bug for this: <a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=275243'>Bugzilla
? Bug 275243</a>
djatnieks
I've found out what I need to do to get this to work, but I think it may still be a Birt bug.<br />
<br />
The key seems to be getting a new ReportDocument object, which then requires getting a new RenderTask object as well.<br />
<br />
IReportDocument reportDocument = engine.openReportDocument(reportDocFile);<br />
IRenderTask rendertask = engine.createRenderTask(reportDocument);<br />
<br />
If I do both these steps inside my locale loop, then it works:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
for each locale {
IReportDocument reportDocument = engine.openReportDocument(reportDocFile);
IRenderTask rendertask = engine.createRenderTask(reportDocument);
rendertask.setLocale( locale );
rendertask.render();
}
</pre>
<br />
I think the bug would be that the locale is bleeding through to the report document.
mwilliams
djatnieks,
Excellent! Was going to suggest a new ReportDocument call each time, but that really seemed like overkill. Definitely update the bug you filed with this new information. Good luck.
djatnieks
If you are using the ReportRunner.java code, it should reproduce by replacing:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
protected int renderReport( )
...
task.setLocale( getLocale( locale ) );
...
task.render( );
</pre>
<br />
with <br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
protected int renderReport( )
...
task.setLocale( getLocale( locale ) );
...
task.render( );
// ADD CODE LIKE THIS AFTER THE FIRST RENDER
task.setLocale( getLocale( anotherlocale ) );
task.render( );
</pre>