connect-gettext
v2.1.0
Published
Lightweight implementation of gettext as connect middleware.
Downloads
7
Maintainers
Readme
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