语言包的问题:缺少列名称

时间:2017-06-15 07:16:19

标签: internationalization jasper-reports

我有一份报告,我正在尝试测试本地化

因此,我将3个语言文件存在于已配置为源路径的文件夹中

现在,报告中的表格有四列。国家,州,名称和年龄。存在3个语言文件language_en_US,langauage_fr_FR,language_pt_PT。根据相应的语言,每个列中的每个列的名称都存在。我已使用$R{}

配置表格列标题的文本表达式
  1. 但是,当我运行报表时,所有列标题的名称都为null。为什么会这样?
  2. 如何在运行时选择不同的语言?报告总是运行en_US,这是默认值?我确实想使用report_locale参数
  3. 我可以使用其他参数,将其值设置为所需的区域设置,然后将此区域设置传递给捆绑包吗?
  4. 请在下面找到jrxml

    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="testinterntionalization" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="languages/languages" uuid="c3bdcfb8-c39a-4ce6-b38c-e7f05aa12d1b">
        <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <subDataset name="Dataset1" uuid="1d6f72b2-0f11-41ac-b81e-e83ff3318002">
            <property name="com.jaspersoft.studio.data.defaultdataadapter" value="mysqldev"/>
            <queryString>
                <![CDATA[select * from testinternationalization;]]>
            </queryString>
            <field name="country" class="java.lang.String">
                <fieldDescription><![CDATA[]]></fieldDescription>
            </field>
            <field name="state" class="java.lang.String">
                <fieldDescription><![CDATA[]]></fieldDescription>
            </field>
            <field name="name" class="java.lang.String">
                <fieldDescription><![CDATA[]]></fieldDescription>
            </field>
            <field name="age" class="java.lang.Integer">
                <fieldDescription><![CDATA[]]></fieldDescription>
            </field>
        </subDataset>
        <parameter name="locale" class="java.lang.String">
            <parameterDescription><![CDATA[]]></parameterDescription>
        </parameter>
        <summary>
            <band height="270" splitType="Stretch">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <textField>
                    <reportElement x="411" y="10" width="100" height="30" uuid="d832c916-8101-4bc1-bc94-2ac5519c0456"/>
                    <textFieldExpression><![CDATA[$P{locale}]]></textFieldExpression>
                </textField>
                <componentElement>
                    <reportElement x="10" y="70" width="510" height="100" uuid="808bf878-b921-4858-b9d4-4dee5c866c89"/>
                    <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                        <datasetRun subDataset="Dataset1" uuid="92016b66-2c36-46c9-b417-ed67c60ebb5c">
                            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                        </datasetRun>
                        <jr:column width="100" uuid="6a314d61-4759-4396-9796-bc890f4018d0">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                            <jr:detailCell style="Table_TD" height="30">
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                                <textField>
                                    <reportElement x="0" y="0" width="100" height="30" uuid="700b5c4a-53ee-4c25-9202-a7cf5960b8f1">
                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                    </reportElement>
                                    <textFieldExpression><![CDATA[$F{country}]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="100" uuid="96d38f9c-1461-4cf6-b43d-5ddc7b031a19">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                            <jr:detailCell style="Table_TD" height="30">
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                                <textField>
                                    <reportElement x="0" y="0" width="100" height="30" uuid="07dbe77e-5f72-44b8-981c-62f4dd5a7fcd">
                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                    </reportElement>
                                    <textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="100" uuid="c26b379e-d8aa-4ede-a79c-b4e521f2bd00">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                            <jr:detailCell style="Table_TD" height="30">
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                                <textField>
                                    <reportElement x="0" y="0" width="100" height="30" uuid="7d71e238-237a-4ff3-83f4-8768995cab50">
                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                    </reportElement>
                                    <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="100" uuid="4581f4df-2aa4-474f-925c-c2d7e4cb7795">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                            <jr:detailCell style="Table_TD" height="30">
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                                <textField>
                                    <reportElement x="0" y="0" width="100" height="30" uuid="50be640f-e779-4ba7-95c7-a92377628278">
                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                    </reportElement>
                                    <textFieldExpression><![CDATA[$F{age}]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                    </jr:table>
                </componentElement>
                <textField>
                    <reportElement x="10" y="40" width="100" height="30" uuid="5b5f292d-2a86-4dfb-a30b-bd3c71d22d79"/>
                    <textFieldExpression><![CDATA[$R{languages.country}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="110" y="40" width="100" height="30" uuid="fdf7454f-068e-4e6f-8f40-e3a0ab8d9fe6"/>
                    <textFieldExpression><![CDATA[$R{languages.state}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="210" y="40" width="100" height="30" uuid="96b616fd-219d-4a74-8a6e-c2143bd45ae3"/>
                    <textFieldExpression><![CDATA[$R{languages.name}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="310" y="40" width="100" height="30" uuid="38acca04-4b84-4975-b74b-ad930f867e21"/>
                    <textFieldExpression><![CDATA[$R{languages.age}]]></textFieldExpression>
                </textField>
            </band>
        </summary>
    </jasperReport>
    

    对此有何帮助?

1 个答案:

答案 0 :(得分:0)

我确实想到了这一点。我不得不将$ R {languages.country}改为$ R {country}。并将resourceBundle =“languages / languages”更改为resourceBundle =“languages”

由于 瑞斯