Navigation Menu

Skip to content

Commit

Permalink
Get it working with Express.js.
Browse files Browse the repository at this point in the history
Fixed request.local to use this instead of (undefined) req.

Fixed request.i18n to bind translate/plural functions into the i18n
context.
  • Loading branch information
assaf committed Nov 16, 2011
1 parent bbbaf4c commit 40b91e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -59,9 +59,9 @@ exports.enableForApp = function enableForApp(app, options, callback) {

// Add "req.locale([locale])" based on session
http.IncomingMessage.prototype.locale = function(newValue) {
var current = req.session[module.exports.localeSessKey];
var current = this.session[module.exports.localeSessKey];
if (typeof newValue != 'undefined') {
req.session[module.exports.localeSessKey] = newValue;
this.session[module.exports.localeSessKey] = newValue;
}
if (typeof current == 'undefined' && typeof defaultLocale != 'undefined') {
current = defaultLocale;
Expand All @@ -71,8 +71,8 @@ exports.enableForApp = function enableForApp(app, options, callback) {

// Add "req.i18n.translate(...)" and "req.i18n.plural(...)"
http.IncomingMessage.prototype.i18n = {
"translate": this.translate,
"plural": this.plural
"translate": exports.translate.bind(exports),
"plural": exports.plural.bind(exports)
};

return callback(undefined, i18n);
Expand Down

0 comments on commit 40b91e3

Please sign in to comment.