-
Notifications
You must be signed in to change notification settings - Fork 15
/
app.js
44 lines (37 loc) · 1.16 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// See https://github.com/mozilla/i18n-abide
// const ejs = require('ejs')
const express = require('express')
const http = require('http')
const i18n = require('i18n-abide')
const path = require('path')
const config = require('../config.json')
const host = config.host
const port = +process.env.PORT || config.port
const app = express()
app.set('port', port)
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
app.use(i18n.abide({
supported_languages: ['de', 'en', 'fr'],
default_lang: 'fr',
translation_directory: 'app/i18n'
}))
app.get('/', function (req, res) {
console.log(req.headers['accept-language'])
res.render('index.ejs', {
title: req.gettext('Hello world')
})
})
// development only
function errorHandler(err, req, res, next) {
res.status(500)
res.render('error', { error: err })
}
if (app.get('env') === 'development') {
app.use(errorHandler)
}
http.createServer(app).listen(port, host, function () {
console.log('Node runtime: ' + process.versions.node + ' (' + process.arch + ')')
console.log('Module search path: ' + (process.env.NODE_PATH || '(none)'))
console.log('Server listening on port ' + port)
})