public
Created — forked from arnklint/i18n.coffee

  • Download Gist
i18n.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
exports.I18n =
en:
title: "Free YouTube video download"
navi:
home: "Home"
howto: "Tutorial"
blog: "Blog"
termsofuse: "Terms of Use"
support: "Support"
imprint: "Imprint"
de:
title: "Kostenloser YouTube Video Download"
navi:
home: "Home"
howto: "Anleitung"
blog: "Blog"
termsofuse: "AGB"
support: "Support"
imprint: "Impressum"
server.coffee
CoffeeScript
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
express = require 'express'
app = express.createServer()
i18n = require('./i18n').I18n
 
# Configure App Server
app.configure ->
app.use express.cookieDecoder()
app.use express.session()
 
# Custom middleware
app.use (req, res, next) ->
req.lang = i18n[req.session.lang]
next()
 
# Other stuff
app.use express.methodOverride()
app.use express.bodyDecoder()
app.use app.router
app.use express.logger()
null
 
app.configure 'development', ->
app.use express.errorHandler {
dumpExceptions: true,
showStack: true
}
null
 
app.configure 'production', ->
app.use express.errorHandler()
null
# Routes
app.get "/", (req, res) ->
res.render 'index.jade', {
locals: { title: req.lang.title }
}
null
 
app.listen 3000

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.