got basic i18n working in express

This commit is contained in:
Henry Oswald 2014-03-24 17:18:58 +00:00
parent 2968fbcfff
commit 063a583ad3
4 changed files with 11 additions and 2 deletions

View file

@ -7,6 +7,7 @@ Server = require("./app/js/infrastructure/Server")
BackgroundTasks = require("./app/js/infrastructure/BackgroundTasks")
Errors = require "./app/js/errors"
argv = require("optimist")
.options("user", {alias : "u", description : "Run the server with permissions of the specified user"})
.options("group", {alias : "g", description : "Run the server with permissions of the specified group"})

View file

@ -48,6 +48,10 @@ module.exports = (app)->
res.locals.settings = Settings
next()
app.use (req, res, next)->
res.locals.translate = req.i18n.translate
next()
app.use (req, res, next)->
res.locals.getSiteHost = ->
Settings.siteUrl.substring(Settings.siteUrl.indexOf("//")+2)

View file

@ -15,6 +15,8 @@ sessionStore = new RedisStore(host:Settings.redis.web.host, port:Settings.redis.
cookieParser = express.cookieParser(Settings.security.sessionSecret)
oneDayInMilliseconds = 86400000
ReferalConnect = require('../Features/Referal/ReferalConnect')
i18n = require("i18next")
i18n.init(resGetPath: 'locales/__lng__/__ns__.json')
Monitor = require "./Monitor"
@ -40,6 +42,7 @@ app.configure ()->
app.set 'views', __dirname + '/../../views'
app.set 'view engine', 'jade'
app.use express.bodyParser(uploadDir: __dirname + "/../../../data/uploads")
app.use i18n.handle
app.use cookieParser
app.use express.session
proxy: true

View file

@ -37,7 +37,8 @@
"archiver": "0.5.1",
"nodetime": "0.8.15",
"mocha": "1.17.1",
"redback": "0.3.7"
"redback": "0.3.7",
"i18next": "~1.7.1"
},
"devDependencies": {
"chai": "",