【问题标题】:Birt report internationalization using datasource instead of resource properties filesBirt 报告国际化使用数据源而不是资源属性文件
【发布时间】:2021-09-16 14:09:33
【问题描述】:

我创建了以下报告:

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.6.0.v201606072122</property>
<simple-property-list name="includeResource">
    <value>Resources</value>
</simple-property-list>
<property name="units">in</property>
<method name="beforeFactory"><! 
[CDATA[reportContext.getDesignHandle().setStringProperty("locale",
params["__locale"].value);]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<parameters>
    <scalar-parameter name="__locale" id="8">
        <property name="valueType">static</property>
        <property name="dataType">string</property>
        <property name="distinct">true</property>
        <list-property name="selectionList"/>
        <property name="paramType">simple</property>
        <property name="controlType">text-box</property>
        <structure name="format">
            <property name="category">Unformatted</property>
        </structure>
    </scalar-parameter>
</parameters>
<page-setup>
    <simple-master-page name="Simple MasterPage" id="2">
        <page-footer>
            <text id="3">
                <property name="contentType">html</property>
                <text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
            </text>
        </page-footer>
    </simple-master-page>
</page-setup>
<body>
    <label id="7">
        <text-property name="text" key="offerte.offerte"></text-property>
    </label>
    <label id="9">
        <text-property name="text" key="offerte.klant"></text-property>
    </label>
</body>

效果很好,但现在我想使用数据源而不是属性文件。有人知道从哪里开始吗?

【问题讨论】:

    标签: internationalization datasource birt


    【解决方案1】:

    属性文件是在 BIRT 中支持国际化的“标准”方式,但您可以按照自己喜欢的方式进行操作。

    例如,在我们的应用程序中,我们使用的是 SQL 数据库。所有的翻译都存储在表格中。输出语言被指定为报告参数。每一次翻译都是在此基础上完成的。

    例如,我们从不使用标签。相反,我们使用动态文本项(根据情况使用纯文本或 html。

    一个小的 javascript 函数 pr(x) 返回文本 x 的翻译。

    如果可能,我们会使用 SQL 进行所有日期和数字格式设置(我不知道是否可以动态更改“格式日期”和“格式数字”属性 - 这也可以)。

    【讨论】:

    • 能否详细介绍一下javascript函数?
    • 思路是:在布局中使用pr("some text")获取目标语言的翻译(例如:德语中的“Irgendein Text”)。报告使用 Javascript 对象(例如报告变量)来存储翻译。 pr 函数只是从该对象获取翻译。您使用 SQL 数据集和 onFetch 事件在报表顶部填充 Javascript 对象一次。这适用于静态文本(标签等)。很容易扫描 XML 源(在开发期间)以查找 pr("...") 以查看必须翻译哪些标签。对于动态数据,直接在 SQL 中做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多