'Node.js + EJS + smws : Multi language support in web app

Currently, I'm building a web app with Node.js with an EJS view engine and SMWS for multilanguage support.

const express = require("express")
const app = express()    
const smws = require('smws'); // Multilanguage 
    
// Implementing the rate limiter
const rate_limiter = require("./middlewares/rateLimiter")
const rateLimiterForAPI = rate_limiter.rateLimiterForAPI; 
const rateLimiterForWeb = rate_limiter.rateLimiterForWeb; 

// Signup page
app.get(smws.split('/:lang/register'), rateLimiterForWeb, (req, res) => {
    smws.run(req,res,{
        page: 'register',
        useParams: ['lang'],
        page404: '404'
    }); 
})

My web app shows the page with the proper language content from the language files en.json and it.json.

My question: When the page loads, I need to do perform some processes and pass the result values to the templates (index.ejs). But I couldn't find the proper documentation from https://www.npmjs.com/package/smws about how to pass the custom parameters to the template files.

Can anyone guide me with this npm package? my main objective is to adapt the multi-language therefore kindly suggest to me the best npm package which I can use instead of SMWS.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source