1.0.1 • Published 8 years ago
express-yalm v1.0.1
express-yalm
Yet Another Language Matcher - middleware for expressjs
what?
Expressjs middleware that matches the visitor's language to the supported or default langauge of an expressjs website or API. According to 3 basic rules:
The most explicit way (querystring) always overrides the other rules.
- Is lang part of the querystring? (i.e. localhost/?lang=en)
- Is there a lang cookie already set?
- Is the language in accept-lang (http header) a supported langauge?
Else it falls back on the default language.
how?
Express-yalm takes only 3 parameters:
- A list of your website/API's supported languages
- The default language of your website/API
- Boolean to set a lang cookie or not
example
var express = require('express');
var yalm = require('express-yalm');
var app = express();
app.use(yalm(['en', 'fr', 'de', 'es', 'nl'], 'en', true));