Permalink
Browse files

update examples for i18n

  • Loading branch information...
1 parent 46781de commit f1466b68feb5d3d1651c02b4b643d9ccdef1af3b @shaunlee committed May 8, 2011
View
@@ -4,24 +4,24 @@
*/
var express = require('express'),
- jst = require('jst');
+ jst = require('jst'),
+ locales = require('locales');
var app = module.exports = express.createServer();
// Configuration
-jst.configure({
- locales: {locales: __dirname + '/locales'}
+locales.configure({
+ locales: __dirname + '/locales'
});
app.configure(function(){
app.set('views', __dirname + '/views');
- //app.set('view engine', 'jst');
- app.register('.html', jst); // Use this for i18n
+ app.set('view engine', 'jst');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(function(req, res, next) { req.lang = 'zh_CN'; next(); });
- app.use(jst.detector);
+ app.use(locales.detector); // for i18n
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
@@ -34,10 +34,15 @@ app.configure('production', function(){
app.use(express.errorHandler());
});
+app.helpers({
+ _: locales.gettext,
+ _n: locales.ngettext
+});
+
// Routes
app.get('/', function(req, res){
- res.render('index.html', {
+ res.render('index', {
title: 'Express'
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f1466b6

Please sign in to comment.