jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

using __ and __n with express-handlebars views #75

Closed nico1510 closed 8 years ago

nico1510 commented 8 years ago

When trying to access a locale property inside a handlebars view like follows:

  <h1>{{ __("someProperty") }} </h1>

I get a Parse Error with the following stack trace:

Error: Parse error on line 46:
... <h1>{{ __("someProperty") }} </h1>
-----------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'
    at Object.parseError (./node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:218:19)
    at Object.parse (./node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:287:30)
    at HandlebarsEnvironment.parse (./node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:45:43)
    at compileInput (./node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:477:19)
    at ret (./node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:486:18)
    at ExpressHandlebars._renderTemplate ./node_modules/express-handlebars/lib/express-handlebars.js:247:12)
    at ExpressHandlebars.<anonymous> (./node_modules/express-handlebars/lib/express-handlebars.js:173:21)

I can only circumvent this by using:

  <h1>{{ __ "someProperty" }} </h1>

Is this the intended use for handlebars or am I missing some helper function ?

nico1510 commented 8 years ago

I just saw that this is the standard way of passing arguments to a helper in handlebars2