@jsreport/jsreport-localization
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -15,5 +15,20 @@ const fs = require('fs').promises | ||
reporter.beforeRenderListeners.add(definition.name, (req) => { | ||
if (req.template.localization?.language != null && req.options.localization?.language == null) { | ||
req.options.localization = Object.assign({}, req.options.localization, { language: req.template.localization.language }) | ||
} | ||
}) | ||
reporter.extendProxy((proxy, req) => { | ||
proxy.localization = { | ||
localize: async function (key, folder) { | ||
let language | ||
if (typeof key === 'object') { | ||
const options = key | ||
key = options.key | ||
folder = options.folder | ||
language = options.language | ||
} | ||
if (key == null) { | ||
@@ -31,6 +46,3 @@ throw new Error('localize expects key parameter') | ||
let language = req.options.localization ? req.options.localization.language : req.options.language | ||
if (!language) { | ||
language = req.template.localization ? req.template.localization.language : null | ||
} | ||
language = language || (req.options.localization ? req.options.localization.language : req.options.language) | ||
@@ -37,0 +49,0 @@ if (!language) { |
{ | ||
"name": "@jsreport/jsreport-localization", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "jsreport extension adding localize helper", | ||
@@ -36,7 +36,8 @@ "keywords": [ | ||
"handlebars": "4.7.7", | ||
"@jsreport/jsreport-assets": "3.2.0", | ||
"@jsreport/jsreport-core": "3.3.0", | ||
"@jsreport/jsreport-assets": "3.3.0", | ||
"@jsreport/jsreport-core": "3.4.0", | ||
"@jsreport/jsreport-components": "3.2.0", | ||
"@jsreport/jsreport-child-templates": "3.0.1", | ||
"@jsreport/jsreport-handlebars": "3.0.0", | ||
"@jsreport/studio-dev": "3.0.1", | ||
"@jsreport/studio-dev": "3.1.0", | ||
"mocha": "8.3.2", | ||
@@ -43,0 +44,0 @@ "should": "13.2.3", |
@@ -10,2 +10,6 @@ # jsreport-localization | ||
### 3.2.0 | ||
accept object for localize function and propagate req.template.localization to the child templates | ||
### 3.0.1 | ||
@@ -12,0 +16,0 @@ |
20436
281
22
10