Skip to content

@umaar /i18n.coffee forked from saschagehlich/i18n.coffee
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple i18n with node.js and express.js
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"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.