Giter Club home page Giter Club logo

Comments (8)

oliversalzburg avatar oliversalzburg commented on July 16, 2024

Seems like #48 could be related.

Given that the question about the bindings came up, I started reading the README a bit more closely. In the end, adding the following code to my application took care of the issue:

  app.use( function( req, res, next ) {
    // express helper for natively supported engines
    res.locals.__i = res.__i = function() {
      return i18n.__.apply( req, arguments );
    };
    res.locals.__n = res.__n = function() {
      return i18n.__n.apply( req, arguments );
    };
    next();
  } );

Then I could also remove this obsolete piece of code:

  app.locals( {
                __i: i18n.__,
                __n: i18n.__n
              } );

And now it's working with the latest and greatest :) Feel free to close if I didn't miss anything.

from i18n-node.

mashpie avatar mashpie commented on July 16, 2024

ok fine :)

you might even omit that custom setup inside app.use if you start using __() instead of __i(). Please review https://gist.github.com/mashpie/5124626 for details. I'd also like to add a jade example, so don't hesitate sharing any hints.

Thanks!

from i18n-node.

oliversalzburg avatar oliversalzburg commented on July 16, 2024

I remember reading that __() doesn't work because jade uses an internal variable named __ which conflicts with this default name. I thought that this is what makes the case with jade special. But I haven't really checked if that still holds true.

from i18n-node.

hanksudo avatar hanksudo commented on July 16, 2024

According this issue: pugjs/pug#403

Jade not use __ anymore. Currently version express + jade + i18n works fine for me

from i18n-node.

mashpie avatar mashpie commented on July 16, 2024

correct.. left this ticket open until setup another example...

from i18n-node.

hanksudo avatar hanksudo commented on July 16, 2024

I just created a example here:

[email protected] + [email protected] + [email protected]
https://gist.github.com/hankwang/5994144

from i18n-node.

mashpie avatar mashpie commented on July 16, 2024

@HankWang haha! same idea over here, see https://github.com/mashpie/i18n-node/tree/master/examples/express-jade - so I'll link your gist in README, ok?

from i18n-node.

hanksudo avatar hanksudo commented on July 16, 2024

@mashpie sure :)

from i18n-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.