Conditionalize Label Translation with JavaScript
Create a report design file and the resource files that enable the translation of its labels.
You can use an
onCreate
JavaScript to override the translation context on a
report design. This enables Report Designer to translate label text based on a
specified condition, rather than the language preference of the user running the
print task. - To add anonCreatescript, select a label on theLayouttab of your report design, then select theScripttab.
- From theScriptdrop-down list, selectonCreate.
- In the text pane, add the appropriate JavaScript.
This example overrides the default language and provides appropriate translation if the locale
is fr_CA:
importPackage(Packages.java.util); if(row["Locale"]=="fr_CA") { var lc = new Locale("fr_CA"); this.text = reportContext.getMessage("Dear", lc);}