-
-
Save slaveofcode/dc765044dd0a3c28d1c73c05892d5435 to your computer and use it in GitHub Desktop.
i18n-node in an restify app setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require modules | |
var restify = require('restify'), | |
i18n = require('i18n'), | |
app; | |
// minimal config | |
i18n.configure({ | |
locales: ['en', 'de'], | |
directory: __dirname + '/locales' | |
}); | |
// Create the RESTify server | |
app = restify.createServer(); | |
// enable i18n in restify | |
app.use(i18n.init); | |
// setup a simple resource | |
app.get('/test', function (req, res, next) { | |
res.send(200, { | |
'somevartoreturn': res.__('Hello') | |
}); | |
return next(); | |
}); | |
// Start the app! | |
app.listen(3000, '127.0.0.1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment