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)
Get externalized text inside script
manjus.kt
Hi,
I spent enough time to find nothing for my problem and would appreciate reply.
The problem is...
Can I access the externalized text(resource messages) inside script, i.e., say for example inside beforeGeneration() event, something similar to this where I'm able to get the report parameter...
context.getExternalContext().getScriptable().getParameterValue("start-date")
I'm trying to set the chart title dynamically from report parameter and externalized text.
Thanks,
Manju
Find more posts tagged with
Comments
mcremer
<blockquote class='ipsBlockquote' data-author="'manjus.kt'" data-cid="83093" data-time="1316600089" data-date="21 September 2011 - 03:14 AM"><p>
Hi,<br />
I spent enough time to find nothing for my problem and would appreciate reply.<br />
<br />
The problem is...<br />
<br />
Can I access the externalized text(resource messages) inside script, i.e., say for example inside beforeGeneration() event, something similar to this where I'm able to get the report parameter...<br />
context.getExternalContext().getScriptable().getParameterValue("start-date")<br />
<br />
<br />
I'm trying to set the chart title dynamically from report parameter and externalized text.<br />
<br />
Thanks,<br />
Manju<br /></p></blockquote>
<br />
What you need is somting like this I guess:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1313-build-professional-looking-charts-with-birt-chart-da-vinci/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1313-build-professional-looking-charts-with-birt-chart-da-vinci/</a><br
/>
<br />
Then you can do this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc ) {
s1 = new Array(); // Axis Options
s2 = new Array(); // Text options
s3 = new Array(); // Custom palette
s1[8] = "Y"; // No stripes
//s1[40] = "248, 248, 248"; // Back Wall Color
s1[16] = "40"; // Widen the bars by narrowing the gap between bars
// Customize the Y Axis scale
// ==========================
s1[400] = "yes"; // Yes, manual scale range
s1[402] = 2800; // Maximum value on Y Axis
s1[403] = 74; // Step size
s1[404] = 120;
s2[01] = vars["chart_name"]; // CHART TITLE
s2[11] = "Deskundige Code"; // X AXIS TITLE
s2[21] = "Aantal"; // Y AXIS TITLE
s2[201] = "0,0,0,0"
// Custom Palette
s3[00] = "88,211,247"
s3[01] = "1,170,210"
s3[02] = "40,150,255"
s3[03] = "0,0,255"
s3[04] = "46,46,254"
s3[05] = "95,4,180"
s3[06] = "180,4,174"
s3[07] = "180,4,95"
s3[08] = "200,4,95"
s3[09] = "223,0,58"
var cdvBuildChart = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable( "cdvBuildChart");
cdvBuildChart(chart, icsc, s1, s2, s3 );
} // End of beforeGeneration
</pre>
<br />
Of course you need to put in the Before Factory:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
vars["chart_name"] = params["chart_name"].value
</pre>
<br />
Hope this helps.
manjus.kt
Hi,
I appreciate your quick response!
Correct me if wrong, I guess the code is getting the title from the report parameters, but what I want is from the externalize text(I'm trying internationalization of report).
Thanks,
Manju
mcremer
<blockquote class='ipsBlockquote' data-author="'manjus.kt'" data-cid="83098" data-time="1316603692" data-date="21 September 2011 - 04:14 AM"><p>
Hi,<br />
I appreciate your quick response!<br />
<br />
Correct me if wrong, I guess the code is getting the title from the report parameters, but what I want is from the externalize text(I'm trying internationalization of report).<br />
<br />
Thanks,<br />
Manju<br /></p></blockquote>
<br />
Then my second question is how do you <a class='bbc_url' href='
http://www.google.nl/url?sa=t&source=web&cd=1&ved=0CBcQFjAA&url=http://en.wikipedia.org/wiki/Internationalization_and_localization&ei=Jsh5TtfOH4L_-ga7qIEw&usg=AFQjCNEcoGtrKS_1aqhEzajHam4Tzst1iQ&sig2=JnNk2fpoNl8zXO6ZiGY50g'>l18n</a>
; your report?<br />
<br />
I mean if your using data sets you could go that way using your databse.<br />
<br />
Or are you using it trough an inbedded file were you have a .porperties file that has the translation?
manjus.kt
Thats right, I use resource message .properties file which holds the translation.
Thanks,
Manju
johnw
You should be able to do it exactly the same way you do in Java, using ResourceBundles. You have access to the entire Java library with BIRT. So, in the beforeFactory or initialize events, you would use something like importPackage(java.util); and instantiate with new ResourceBundle(). Or just use Packages.java.util.ResourceBundle. I have found the most success using external event handlers. It is possible using the Javascript too, but finding the right classpath to stash the property files is a bit of a pain. I will put together an example and post it on my blog, and post the link.
Is there any reason you don't use the built in localization?
manjus.kt
<blockquote class='ipsBlockquote' data-author="'mcremer'" data-cid="83097" data-time="1316602295" data-date="21 September 2011 - 03:51 AM"><p>
What you need is somting like this I guess:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1313-build-professional-looking-charts-with-birt-chart-da-vinci/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1313-build-professional-looking-charts-with-birt-chart-da-vinci/</a><br
/>
<br />
Then you can do this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc ) {
s1 = new Array(); // Axis Options
s2 = new Array(); // Text options
s3 = new Array(); // Custom palette
s1[8] = "Y"; // No stripes
//s1[40] = "248, 248, 248"; // Back Wall Color
s1[16] = "40"; // Widen the bars by narrowing the gap between bars
// Customize the Y Axis scale
// ==========================
s1[400] = "yes"; // Yes, manual scale range
s1[402] = 2800; // Maximum value on Y Axis
s1[403] = 74; // Step size
s1[404] = 120;
s2[01] = vars["chart_name"]; // CHART TITLE
s2[11] = "Deskundige Code"; // X AXIS TITLE
s2[21] = "Aantal"; // Y AXIS TITLE
s2[201] = "0,0,0,0"
// Custom Palette
s3[00] = "88,211,247"
s3[01] = "1,170,210"
s3[02] = "40,150,255"
s3[03] = "0,0,255"
s3[04] = "46,46,254"
s3[05] = "95,4,180"
s3[06] = "180,4,174"
s3[07] = "180,4,95"
s3[08] = "200,4,95"
s3[09] = "223,0,58"
var cdvBuildChart = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable( "cdvBuildChart");
cdvBuildChart(chart, icsc, s1, s2, s3 );
} // End of beforeGeneration
</pre>
<br />
Of course you need to put in the Before Factory:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
vars["chart_name"] = params["chart_name"].value
</pre>
<br />
Hope this helps.<br /></p></blockquote>
manjus.kt
Hi,
I'm using the built in functionality, am I missing anything here?
Thanks,
Manju
mcremer
<blockquote class='ipsBlockquote' data-author="'manjus.kt'" data-cid="83143" data-time="1316674268" data-date="21 September 2011 - 11:51 PM"><p>
Hi,<br />
I'm using the built in functionality, am I missing anything here?<br />
<br />
Thanks,<br />
Manju<br /></p></blockquote>
<br />
Try:<br />
<br />
<a class='bbc_url' href='
http://wiki.eclipse.org/BIRT/FAQ/Internationalization'>http://wiki.eclipse.org/BIRT/FAQ/Internationalization</a>
;
manjus.kt
Hi mcremer,
That's exactly what I needed, thanks a ton!!!!
Thanks,
Manju