i18next / i18next-express-middleware

[deprecated] can be replaced with i18next-http-middleware
https://github.com/i18next/i18next-http-middleware
MIT License
206 stars 52 forks source link

not work pug.renderFile #212

Closed genikineg closed 4 years ago

genikineg commented 4 years ago

TypeError: /static/Main/Main.pug:5 3| head 4| meta(http-equiv='Content-Type', content='text/html; charset=utf-8')

5| title= t('home.title') 6| meta(name='format-detection', content='telephone=no') 7| meta(name='viewport', content='initial-scale=1 user-scalable=no') 8| meta(name='description', content='({ description })')

t is not a function

adrai commented 4 years ago

Here it seems to work: https://github.com/i18next/i18next-http-middleware/tree/master/example/basic-pug

Probably you are not setting the locals. Like here: https://github.com/i18next/i18next-http-middleware/blob/master/lib/index.js#L85

Please provide a reproducable example.

genikineg commented 4 years ago

Here it seems to work: https://github.com/i18next/i18next-http-middleware/tree/master/example/basic-pug

Probably you are not setting the locals. Like here: https://github.com/i18next/i18next-http-middleware/blob/master/lib/index.js#L85

Please provide a reproducable example.


app.get('/', function (req, res, next) {
  return res.send(pug.renderFile(
    dir+'/static/Main/Main.pug',
    {
      title: 'Main',
      description: 'description',
      keywords: 'keywordssdsd232',
      req: req
    }
  ))
});
doctype transitional
html.js.no-touch
  head
    meta(http-equiv='Content-Type', content='text/html; charset=utf-8')
    title= t('home.title')

I need to use pug.renderFile for my cache system

adrai commented 4 years ago

pass t, like title... t: req.t,

btw. i18next-express-middleware is deprecated, use i18next-http-middleware instead

genikineg commented 4 years ago

pass t, like title... t: req.t,

btw. i18next-express-middleware is deprecated, use i18next-http-middleware instead

Thanks!