Add support of i18n with related patches and support "en" and "zh" locales for now

This commit is contained in:
Wu Cheng-Han
2016-08-19 11:49:24 +08:00
parent 87f4d05e8e
commit b9c59c454d
14 changed files with 400 additions and 147 deletions

11
app.js
View File

@@ -16,6 +16,7 @@ var formidable = require('formidable');
var morgan = require('morgan');
var passportSocketIo = require("passport.socketio");
var helmet = require('helmet');
var i18n = require('i18n');
//core
var config = require("./lib/config.js");
@@ -92,6 +93,16 @@ app.use(helmet.hsts({
preload: true
}));
i18n.configure({
locales: ['en', 'zh'],
cookie: 'locale',
directory: __dirname + '/locales'
});
app.use(cookieParser());
app.use(i18n.init);
// routes without sessions
// static files
app.use('/', express.static(__dirname + '/public', { maxAge: config.staticcachetime }));