i18n-stack
v1.0.0
Published
Stack of connect middleware for language/locale detection and translation.
Downloads
2
Maintainers
Readme
i18n-stack
Stack of connect middleware for language/locale detection and translation.
- detectLanguage - parse and detect browser language preference
- overwriteLanguage - overwrite language selection with query param and/or cookie
- gettext - insert simple gettext implementation in response
Also exposes parseAcceptLanguage - in case if you need parsed form
of Accept-Language
header for some other reason than language selection.
If you don't need this exact stack all of its components can be used separately.
Install
$ npm install --save i18n-stack
Usage
var app = require('express');
var locale = {
supportedLanguages: ['de', 'fr', 'pl', 'en-GB', 'en-US'],
defaultLanguage: 'en',
gettextAlias: '_'
};
var i18n = require('i18n-stack');
app.use(i18n.overwriteLanguage(locale));
app.use(i18n.detectLanguage(locale));
app.use(i18n.gettext(locale));
License
MIT © Damian Krzeminski