I actually found the solution and got the locale via jsreport.req.options.localization.language
P
pastr
@pastr
0
Reputation
2
Posts
235
Profile views
0
Followers
0
Following
Posts made by pastr
-
RE: Get the current locale in global helpers
-
Get the current locale in global helpers
Hello,
I have a global function to format date.
function formatDate(timestampStr) { const timestamp = parseInt(timestampStr) const date = new Date(timestamp); const options = { day: 'numeric', month: 'long', year: 'numeric' }; return date.toLocaleDateString('fr-FR', options); }
As you can see the locale in this example is "fr-FR", instead I would like to have the locale of the template. I can't find a way to get it from the javascript.
Any ideas?