13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

InternationalizationFigure 17-6New localeBy confirming the choice, a new file will be created in the same directory as the default one; it will have the proper localizationabbreviation appended to the file name, and it will be visible as a child of the bundle node in the Favorites view.17.2 Retrieving Localized StringsThere are two ways to retrieve the localized string for a particular key inside a JasperReports expression:• Use the built-in str("key name") function• Use the special syntax $R{key name}Here is an example expression for retrieving a localized string:$R{hello.world}UR converts the text associated with the key hello.world using the most appropriate available translation for theselected locale.17.3 Formatting MessagesThe internationalization features included with UR are based on the support provided by Java. One of the mostuseful features is the msg function, which you can use to dynamically build messages using arguments. In fact, msg usesstrings as patterns. These patterns define where arguments, passed as parameters to the msg function, must be placed. Theposition of an argument is expressed using numbers between braces, as in this example:“The report contains {0} records.”The zero specifies where to place the value of the first argument passed to the msg function. The expression:msg($R{text.message}, $P{number})uses the string referred to by the key text.message as the pattern for the call to msg. The second parameter is the firstargument to be replaced in the pattern string. If text.message is the string “The report contains {0} records.” andthe value for the report parameter number is 100, UR displays the interpreted text string as:The report contains 100 records.327

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!