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

awilcox
Member
Registered: 2015-03-02
Posts: 40

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
Posts: 690

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
Posts: 690

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
Posts: 40

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
Posts: 690

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
Posts: 40

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
Posts: 4

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
Posts: 1,789
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

Board footer

Powered by FluxBB