I'm new to Node.js and I'm trying to learn how to use i18n in my Pug template and could not find my answer anywhere.
The documentation says
in your templates (depending on your template engine)
<%= __('Hello') %>
${__('Hello')}
So far I tried (in my pug template)
${__('Hello')}
__('Hello')
None of those syntax is working, what is the correct one to use ?
I know it is well configure because when using
i18n.__('Hello')
And sending it to my template in a variable it is working.
Answer was right in the documentation, only needed to add this to my configuration.
app.use(function(req, res, next) {
// express helper for natively supported engines
res.locals.__ = res.__ = function() {
return i18n.__.apply(req, arguments);
};
next();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With