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)
Localization problem
birtslash
hi guys<br />
<br />
in my report i use different methods for the localization.<br />
<br />
for simple values, i use the built-in BIRT feature and two seperate resource files, one for english and one for german (i.e. myReport_de_DE.properties and myReport_en_US.properties). then i localize the field values via the "Properties > Localization" dialogue. <br />
<br />
for elements containing "composite" values, such as messages using variables, i'm localizing the values via scripting. <br />
<br />
first, in the report's <em class='bbc'>initialize</em> method i set the global variable <em class='bbc'>lc</em> used as locale:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var l = params["locale"].value;
var arrL = l.split("_", 2);
lc = new Locale(arrL[0], arrL[1]);
</pre>
then, in the element to be localized i use for instance: <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage( Packages.java.util );
arrParams = new Array(2); arrParams[0] = params["A"].value; arrParams[1] = params["B"].value;
reportContext.getMessage("msg_AB", lc, arrParams);
</pre>
<br />
in the report preview everything is displayed as expected, i can switch between different locales via "Preferences > Report Design > Preview > Choose your locale", the output is localized as desired.<br />
<br />
the problem appears when i generate the report via the ReportEngine API in the java code. when rendering the report i call "<em class='bbc'>runAndRenderTask.setLocale(reportLocale);</em>" for the <em class='bbc'>RunAndRenderTask</em>. My "<em class='bbc'>locale</em>" parameter is set correctly within my parameter map which i pass to the report design via "<em class='bbc'>runAndRenderTask.setParameterValues(mapReportParams);</em>". <br />
<br />
when the report is generated (either as html or pdf output), all values localized via scripting (i.e. via "getMessage(...)") are OK, but the localization via the built-in feature fails. It seems that the locale passed to the RunAndRenderTask is just ignored, instead that the system's locale is used. <br />
<br />
so do you have any hints on how to fix this behaviour?<br />
<br />
thanks in advance for any help, regards<br />
bartek
Find more posts tagged with
Comments
kclark
Can you post your code for me to take a look at?
birtslash
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="114784" data-time="1362437041" data-date="04 March 2013 - 03:44 PM"><p>
Can you post your code for me to take a look at?<br /></p></blockquote>
<br />
OK. sorry, my bad! finally i found the culprit;)... <br />
i assumed the birt engine would fall back to the correct locale, but it doesn't. my mistake was to use <em class='bbc'>setLocale(new Locale("en"))</em> or <em class='bbc'>"de"</em>. it did not work since but my resource files names end with "en_US" / "de_DE". using of <em class='bbc'>new Locale(lanugange, country))</em> helps here but i decided to simply rename my resource files to "en" / "de". now localization works even if i set the locale by using both language and country arguments.<br />
<br />
regards<br />
bartek