1.0.1 • Published 8 years ago

express-yalm v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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.

  1. Is lang part of the querystring? (i.e. localhost/?lang=en)
  2. Is there a lang cookie already set?
  3. 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:

  1. A list of your website/API's supported languages
  2. The default language of your website/API
  3. 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));