-
-
Save nicosommi/a513bf2d1feea10794bd to your computer and use it in GitHub Desktop.
example for i18n-node issue #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module dependencies. | |
*/ | |
var express = require('express') | |
, routes = require('./routes') | |
, user = require('./routes/user') | |
, http = require('http') | |
, path = require('path') | |
, i18n = require('i18n'); | |
var app = express(); | |
i18n.configure({ | |
locales: ["en", "es"], | |
register: "global", | |
defaultLocale: "en", | |
directory: "./locales", //default does not work | |
extension: "js", | |
debug: true | |
}); | |
// all environments | |
app.set('port', process.env.PORT || 3000); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(express.favicon()); | |
app.use(express.logger('dev')); | |
app.use(express.bodyParser()); | |
app.use(express.methodOverride()); | |
app.use(express.cookieParser('your secret here')); | |
app.use(express.session()); | |
app.use(express.static(path.join(__dirname, 'public'))); | |
app.use(i18n.init); //init MUST be before app.use(app.router); | |
app.use(app.router); | |
// development only | |
if ('development' == app.get('env')) { | |
app.use(express.errorHandler()); | |
} | |
app.get('/', routes.index); | |
app.get('/users', user.list); | |
http.createServer(app).listen(app.get('port'), function(){ | |
console.log('Express server listening on port ' + app.get('port')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "express" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "expreso espanol", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctype 5 | |
html | |
head | |
link(rel='stylesheet', href='/stylesheets/style.css') | |
body | |
h1=globaltitle | |
Wellcome #{__('title')} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* GET home page. | |
*/ | |
var i18n = require('i18n'); | |
exports.index = function(req, res){ | |
i18n.setLocale('en'); | |
res.render('index', {globaltitle: i18n.__('title')}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment