Hello, I have recently started using jsreport and came across a problem that despite trying to investigate how to work around it, I can't seem to find a way.
This is my structure (I have i18n and translations as I was trying to run some tests):
In my contentRaw
, I have something like this, to access a specific translation, based on the @key
<c t="inlineStr" s="7"><is><t>{{localize @key "../../translations"}}</t></is></c>
Like this, it works, if I am accessing a key directly (in this case, tmax)
But what I wanted to do was something like <c t="inlineStr" s="7"><is><t>{{localize historicalWateringChart.@key "../../translations"}}</t></is></c>
, so I could access historicalWateringChart.tmax, historicalWateringChart.tmin
and so on...
I also have in my StoockDataFetch/content.js (my script file), on my beforeRender
function, the following:
const i18n = await jsreport.localization.localize({
key:'t',
folder: '../../i18n',
language: 'en-GB'
})
req.data.myData = [{}, {
name: i18n.shared.datePeriod,
text: formatDate(req.data.startDate) + " - " + formatDate(req.data.endDate)
},]
Like this it works, but I was trying to understand if there is another way to get my i18n, as on my json
file for my i18n translations, it needs to be set up like this:
{"t": {
"shared": {
"datePeriod": "Date period",
}}
And I wanted to get rid of the t
key, but by accessing jsreport.localization.localize()
, the key
is obligatory.
Any sort of help would be highly appreciated, and if I wasn't clear or you need for me to provide more information please do tell.