akoenig/express-lingua — Issue #6: Express 2.4.7 compatibility
Author: mglcel
Created: 2011-10-22 19:55:56+00:00
State: open

Hi, in order to get lingua running with Express 2.4.7, i have made a simple modification in lingua.js, not sure of what's occured with this version...

I also added a '\_' var which permits a direct access to the i18n 'content', simplifying the templates definition, using for instance in jade #{\_.description}, #{lingua.content.description} is already accessible.., don't know if its a feature you want to keep.

The diff below (from 0.2.1) :

```
lingua.js
71a72,94
> // The middleware function.
> //
> // description:
> // This function will be called on every single
> // HTTP request.
> //
> var lingua = function (req, res) {
> //
> // Determine the locale in this order:
> // 1. URL query string, 2. Cookie analysis, 3. header analysis
> //
> var locales = trainee.determineLocales(req, res);
>
> var resource = guru.ask(locales);
> var locale = resource.locale;
>
> trainee.persistCookie(req, res, locale);
>
> return resource;
> };
>
> //
> // summary:
108a132,134
> if ( ! res.lingua ) {
> res.lingua = lingua(req, res);
> }
109a136,138
> },
> _: function(req, res) {
> return res.lingua.content.content;
113,134c142,143
< //
< // summary:
< // The middleware function.
< //
< // description:
< // This function will be called on every single
< // HTTP request.
< //
< return function lingua(req, res, next) {
< //
< // Determine the locale in this order:
< // 1. URL query string, 2. Cookie analysis, 3. header analysis
< //
< var locales = trainee.determineLocales(req, res);
<
< var resource = guru.ask(locales);
< var locale = resource.locale;
<
< trainee.persistCookie(req, res, locale);
<
< res.lingua = resource;
<
---
> return function (req, res, next) {
> res.lingua = lingua(req, res);
136,137c145,146
< };
< };
---
> }
> };
```