I want to create a document, which prints in more than one language, based on the Locale
.
I have created 2 resource bundles, one in English and one in Chinese, but I am not sure how to use them.
Google Translate is a no-cost service provided by Google. It is by far the easiest and more common way to add multiple language support to your website. To add Google Translate to your site, you simply sign up for an account and then paste a small bit of code to the HTML.
Here is the sample of how to implement internationalization support for JasperReports.
The main idea is to use special expression $R{}
for localizing text and images.
The sample for images:
<image scaleImage="Clip">
<reportElement positionType="Float" x="20" y="20" width="100" height="50"/>
<imageExpression class="java.lang.String"><![CDATA[$R{image.flag}]]></imageExpression>
</image>
The samples for text (the $R{} syntax):
<textField isBlankWhenNull="true">
<reportElement x="20" y="100" width="530" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{sampleString}]]></textFieldExpression>
</textField>
or (the msg() method):
text.message=The program picked up {0} as a random number.
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="20" y="210" width="530" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[msg($R{text.message}, $P{number})]]></textFieldExpression>
</textField>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With