#1 2015-04-09 18:30:17

awilcox
Member
Registered: 2015-03-02

Localization for BIRT reports

We have a BIRT report that requires localization (English and French). The property files (x_en.properties and x_fr.properties) were added to ReportServer's filesystem. The configuration file reportengines.cf was edited such that the Birt library folder <id> value reflects the id of the folder where the Birt property files are loaded.

When I log into ReportServer in English and run the report, the x_en.properties file is used.

When I log into ReportServer in French, the locale in the URL shows "fr", but when I run the report the x_en.properties file is used, not x_fr.properties as I would expect.

To get the user's local in ReportServer passed to Birt and get the French property file used, I had to do the following (similar to another forum post), and then in the Birt report itself I had to explicitly set the locale to this passed in parameter.

import net.datenwerke.rs.core.service.reportmanager.hooks.ParameterSetReplacementProviderHook;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.Report;
import net.datenwerke.security.service.usermanager.entities.User;
import net.datenwerke.rs.core.service.reportmanager.parameters.*;
import net.datenwerke.rs.utils.localization.LocalizationServiceImpl;

def LocalizationServiceImpl localizationService = GLOBALS.getRsService(LocalizationServiceImpl.class);
replacementProvider = new ParameterSetReplacementProviderHook(){
    @Override
    public Collection<? extends ParameterSetReplacementProvider> getProviders() {
        Set<ParameterSetReplacementProvider> providers = new HashSet<ParameterSetReplacementProvider>();
        def testProvider = new ParameterSetReplacementProviderImpl() {
            @Override
            public Map<String, ParameterValue> provideReplacements(User user, Report report) {
                Locale locale = localizationService.getLocale();
                Map<String, ParameterValue> res = new HashMap<String, ParameterValue>();
                res.put("rpLocale", new ParameterValueImpl("rpLocale",locale, String.class));
                return res;
            }
        };
        providers.add(testProvider);
        return providers;
    }
};
GLOBALS.services.callbackRegistry.attachHook("LOCAL_PARAM_PROV", ParameterSetReplacementProviderHook.class, replacementProvider);

1. Is there a cleaner way for ReportServer to pass the locale to the Birt engine, or is it necessary to take an approach like I've described above?

2. Also, would it be possible to change the Birt library folder configuration in reportengines.cf such that it uses maybe a path instead of a database ID? Using a database ID makes it difficult to use the same configuration file across multiple environments.

Offline

#2 2015-04-12 07:44:16

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Localization for BIRT reports

Hi Alana,

what you have there is currently I think the best solution to get access to the current locale. I've created a feature request ticket as I think this is something that should be available out of the box.

As for 2) we'll look into this.

Cheers,
-Arno

Offline

#3 2015-04-12 07:53:09

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Localization for BIRT reports

Hi Alana,

I just had a quick look at the code. You should directly be able to specify a path instead of an ID, if you use

<library>
   <folder> 
      <path>MY PATH</path>
   </folder> 
</library>

Cheers
-Arno

Offline

#4 2015-04-13 14:59:51

awilcox
Member
Registered: 2015-03-02

Re: Localization for BIRT reports

Hi Arno,

I was able to specify a path instead of ID as you suggested, thanks!

As for sending the locale to Birt out of the box vs having to implement the manual approach as described, that would be great! Is there any way to see or find out when a feature ticket has been implemented and included in a release?

Thanks,
Alana

Offline

#5 2015-04-14 06:26:51

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Localization for BIRT reports

Hi Alana,

I've raised a "reminder ticket" in the support portal and will get back to you when its implemented.

Cheers
-Arno

Offline

#6 2015-04-15 19:52:13

awilcox
Member
Registered: 2015-03-02

Re: Localization for BIRT reports

As a followup to this question, the localization using property files is working well for the generated report. Is there a way to also localize the name of the parameters in Report Server?

The Birt .rptdesign file has the "Prompt text key" for the parameter pointing to a key in the property file (similar to how the labels in the generated report are pointing to keys in the property file), but when I add parameters in ReportServer, I don't see a way to make use of this.

Offline

#7 2020-08-14 15:35:51

davejal
Member
Registered: 2020-08-05

Re: Localization for BIRT reports

Hi Awilcox,

I'm trying to set up localization. Could you add the exact steps to use reportengines.cf?
In birt I can pass parameter en_US to get English and nl_NL to get the report in dutch. When executed in birt the languages are displayed correctly, but in reportserver I only get NULL for the labels.

Where do I place the file reportengines.cf?
How to change the file?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <birt>
      <library>
         <folder>
            <id>1</id>
         </folder>
      </library>
      <enable>true</enable>
   </birt>
   <jasper>
      <enable>true</enable>
      <allowedlanguages>groovy</allowedlanguages>
   </jasper>
</configuration>

Thanks in advance

Offline

#8 2020-09-28 09:03:18

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Localization for BIRT reports

Hi davejal,

can you pls post a minimal .rpt report with 1-2 labels where localization works in the BIRT environment ?

Regards,
Eduardo

Offline

#9 2021-01-28 12:09:45

adasan
Member
Registered: 2016-12-27

Re: Localization for BIRT reports

Hi Eduardo,

I have not succeeded either. This is the .rpt report and the localization files

<?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>test/trad</value>
    </simple-property-list>
    <property name="units">in</property>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="bidiLayoutOrientation">ltr</property>
    <property name="imageDPI">96</property>
    <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="4">
            <text-property name="text" key="hello">hello</text-property>
        </label>
        <label id="5">
            <text-property name="text" key="thanks">thanks</text-property>
        </label>
    </body>
</report>


And the files with localization, that they are on "test" directory on my Eclipse.
trad.properties
hello=Hello
thanks=Thanks

trad_es_ES.properties
hello=Hola
thanks=Gracias

Regards,
Adasan

Offline

#10 2021-06-28 18:23:46

davejal
Member
Registered: 2020-08-05

Re: Localization for BIRT reports

eduardo wrote:

Hi davejal,

can you pls post a minimal .rpt report with 1-2 labels where localization works in the BIRT environment ?

Regards,
Eduardo

Hi Eduardo,


This is my minimal rptdesign file.


<?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/Resources</value>
    </simple-property-list>
    <property name="units">in</property>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="bidiLayoutOrientation">ltr</property>
    <property name="imageDPI">96</property>
    <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="4">
            <text-property name="text" key="offerte.offerte">Offerte</text-property>
        </label>
        <label id="5">
            <text-property name="text" key="offerte.klant">Klant</text-property>
        </label>
    </body>
</report>

these are the 2 properties files:
Resources_nl_NL.properties
offerte.offerte=Offerte
offerte.klant=Klant

Resources.properties
offerte.offerte=Quotation
offerte.klant=Customer

A reference of how it works:
https://www.youtube.com/watch?v=x4bjNOqOpLU

Any help would be appreciated.

Offline

#11 2021-07-08 12:06:11

jalbrecht
Administrator
Registered: 2016-10-21

Re: Localization for BIRT reports

Hi davejal,

we created ticket RS-5038 and will post here when we have more information.

Regards,
Jan

Offline

Board footer

Powered by FluxBB