How to create a multilingual report?

I want to create a document that prints in several languages, based on Locale.

I created 2 resource packs, one in English and one in Chinese, but I'm not sure how to use them.

+5
source share
2 answers

Here is a sample on how to implement JasperReports internationalization support.

The main idea is to use a special expression $R{}to localize text and images.

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>

Samples for text ($ 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 (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>
+4
source

, - , , .

, if, Locale , .

jrxml . .

, .

SQL- , Query jrxml, .

0

All Articles