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 i18n-2 in models #60

Closed pierissimo closed 9 years ago

pierissimo commented 9 years ago

Hi!

I would to use i18n-2 in models js files, during data valitation. How to access i18n2 functions?

I tried with

var i18n = require('i18n-2');

var validationError = i18n.__("Validation error");

but i get "i18n.__("Validation error") ^ TypeError: undefined is not a function"

What am i doing wrong?

Thanks

gjuchault commented 9 years ago

Hi !

You must instanciate i18n before. Check the examples in the Readme ! Le 4 juil. 2015 16:29, "Piero Maltese" notifications@github.com a écrit :

Hi!

I would to use i18n-2 in models js files, during data valitation. How to access i18n2 functions?

I tried with

var i18n = require('i18n-2');

var validationError = i18n.__("Validation error");

but i get "i18n.__("Validation error") ^ TypeError: undefined is not a function"

What am i doing wrong?

Thanks

— Reply to this email directly or view it on GitHub https://github.com/jeresig/i18n-node-2/issues/60.

pierissimo commented 9 years ago

Ok, i thought that use expressBind was enough. Thank you