Programatically implementing I18n!!!
Options
Hi All,
I have a .rptdesign & .properties (for i18n) files. Now, I want to know that how can I access these .properties file to localize the text in .rptdesign at runtime. I want this to be done using either Engine api or Design api.
Could I use ResourceBundle? Then please provide me to integrate ResourceBundle with BIRT api.
Thanks in advance.
DHAVAL
I have a .rptdesign & .properties (for i18n) files. Now, I want to know that how can I access these .properties file to localize the text in .rptdesign at runtime. I want this to be done using either Engine api or Design api.
Could I use ResourceBundle? Then please provide me to integrate ResourceBundle with BIRT api.
Thanks in advance.
DHAVAL
0
Comments
-
Hi Dhaval,
If you are trying to change out the properties file at runtime, you can do this in the beforeFactory method with syntax like below:
var rr = reportContext.getReportRunnable();
rr.designHandle.setProperty("includeResource", "MyResources");
You can also assign the textkey that gets evaluated in the name/value pait to a label by using:
onPrepare() method of label...
this.textKey = "welcome";
or from anywhere else...
reportContext.getReportRunnable().getDesignInstance().getLabel("GoodbyeLabel").textKey = "goodbye";Warning No formatter is installed for the format ipb0 -
Thanks vdodson for you reply! I have one more thing. Can we do I18n by using ReportEngine api. If it is possible then please help us.
I have inserted a Group field in the crosstab which is having few entries, now I have got their mapping in resource files (.properites) for each langauge & not in designer. So, how could I do that mapping using only ReportEngine api, i.e. IRunTask or IRenderTask or IRunAndRenderTask.
Again thanks in advance.
DHAVAL0 -
If you are trying to set the location of the properties files at runtime using the REAPI, then you can call <br />
config.setResourcePath("C:/work/eclipse/BIRT_221/resources"); <br />
from the EngineConfig.<br />
<br />
You can also assign the locale at runtime with something like:<br />
task.setLocale(ULocale.FRENCH);<br />
<br />
You will need to get a handle on the report design if you want to start assigning resource keys to individual elements like below.<br />
<br />
IReportRunnable design = null;<br />
ReportDesignHandle dh = null;<br />
<br />
design = engine.openReportDesign("C:/workspace_221/birt/Localization.rptdesign"); <br />
dh = (ReportDesignHandle) design.getDesignHandle();<br />
<br />
LabelHandle mylabel = (LabelHandle) dh.findElement("LastLabel");<br />
mylabel.setTextKey("welcome");<br />
<br />
... and in your case where you want a dynamically assigned textkey based on the group there may be some extra work. There may be a better way, but you can use the Mapping feature to assign a resource key. I've created an example reportdesign that does this (link below) and if you want to assign these mappings using the REAPI, it would look something like below.<br />
<br />
ReportItemHandle dataitem = (ReportItemHandle) dh.findElement("OfficeGroupField");<br />
MapRule mr = StructureFactory.createMapRule();<br />
mr.setTestExpression("row["OFFICECODE"]");<br />
mr.setOperator(DesignChoiceConstants.MAP_OPERATOR_EQ);<br />
mr.setValue1("7");<br />
mr.setDisplayKey("7");<br />
<br />
PropertyHandle ph = dataitem.getPropertyHandle(StyleHandle.MAP_RULES_PROP);<br />
ph.addItem(mr);<br />
<br />
<br />
The example has been uploaded to:<br />
<a class='bbc_url' href='http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=351'>http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=351</a>Warning No formatter is installed for the format ipb0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 123 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management