Hi, I'm trying to use jsreport.localization.localize
as shown in the example in the "Complex use case" of the localization documentation (https://jsreport.net/learn/localization) and it works fine when I use the studio, but when I render the report from Javascript code I get this error:
TypeError: Cannot read properties of undefined (reading 'localize')
One reason may be that I'm using jsreport-core to render from Javascript. I don't know if it has something to do with the error.
const jsreport = require('@jsreport/jsreport-core')(options);
jsreport.use(require('@jsreport/jsreport-assets')());
jsreport.use(require('@jsreport/jsreport-chrome-pdf')());
jsreport.use(require('@jsreport/jsreport-data')());
jsreport.use(require('@jsreport/jsreport-fs-store')());
jsreport.use(require('@jsreport/jsreport-jsrender')());
jsreport.use(require('@jsreport/jsreport-pdf-utils')({ syncModifications: false }));
jsreport.render({
template: {
name: reportName
},
data,
options: {
localization: { language: 'en' },
}
});
One thing I've noticed is that when printing the jsreport-proxy properties in the helper, it does not have the 'localization' property when rendering form JS, whereas that property exists when rendering from the studio.
const jsreport = require('jsreport-proxy');
console.log(Object.keys(jsreport));
Is there anything else I need to import in order to use the localize function in the helper?
Thank you.