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

Internationalization 语言包问题:缺少列名称,internationalization,jasper-reports,Internationalization,Jasper Reports,我有一份报告,我正在尝试测试本地化 因此,我有3个语言文件存在于一个配置为源路径的文件夹中 现在,报告中的表有四列。国家、州、姓名和年龄。3个语言文件为当前语言、langauage、fr、language、pt。这些列的名称根据各自的语言显示在每个文件中。我已经用$R{} 但是当我运行报告时,所有列标题的名称都为null。为什么会这样 如何在运行时选择不同的语言?报告始终为en_US运行,这是默认值?我确实想使用report\u locale参数 我是否可以使用另一个参数,将其值设置为所需的区域

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

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

现在,报告中的表有四列。国家、州、姓名和年龄。3个语言文件为当前语言、langauage、fr、language、pt。这些列的名称根据各自的语言显示在每个文件中。我已经用
$R{}

  • 但是当我运行报告时,所有列标题的名称都为null。为什么会这样
  • 如何在运行时选择不同的语言?报告始终为en_US运行,这是默认值?我确实想使用report\u locale参数
  • 我是否可以使用另一个参数,将其值设置为所需的区域设置,然后将该区域设置传递给捆绑包 请在下面找到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>
    
    
    

    有什么帮助吗?

    我确实找到了答案。我必须把$R{languages.country}变成$R{country}。并将resourceBundle=“languages/languages”更改为resourceBundle=“languages”

    谢谢
    Rathi

    您应该发布:1)测试此模板的代码;2) 包含资源的文件夹结构(属性文件位于何处,名称是什么)嗨,Alex,除了这个jrxml,我还没有写任何额外的代码。抱歉,我对这个功能还不熟悉。属性文件位于MyReport/language文件夹下,其中包含3个文件langauges_en_US.properties、langauges_fr_fr.properties和langauges_pt_pt.properties。您有
    resourceBundle=“languages/languages”
    -这意味着JR引擎正在查找
    语言*.properties
    文件在
    languages
    folderHi Alex,我确实拥有languages文件夹下的所有languages.*.properties。但是我不明白为什么它将resourceBundle作为“语言/语言”,我猜您会得到null,因为您没有向主数据源添加任何查询。