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?



  • I actually found the solution and got the locale via jsreport.req.options.localization.language


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.