npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

connect-gettext

1.1.1 • Public • Published

NPM version Build Status Dependency Status

connect-gettext

Lightweight implementation of gettext as connect middleware.

Install

$ npm install --save connect-gettext

Usage

Use with any middleware that sets req.lang - such as detect-language and/or overwrite-language.

var app = require('express');
 
var locale = {
  supportedLanguages: ['de', 'fr', 'pl', 'en-GB', 'en-US'],
  defaultLanguage: 'en',
  gettextAlias: '_'
};
 
// use any middleware that sets req.lang
// `detect-language` is just an example
app.use(require('detect-language')(locale));
 
 
app.use(require('connect-gettext')(locale));
 

Once the middleware is applied res.locals.gettext will have gettext implementation inserted and res.render will be able to use it when rendering pages.

 p
   | #{_("This is how you can use it")}
   span= _("with Jade")

License

MIT © Damian Krzeminski

install

npm i connect-gettext

Downloadsweekly downloads

4

version

1.1.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability