express-langs
request
for easier use with express
parse langs from resolve langagues accept in header
request
getarray
langagues withrequest.langs
Installation
npm install express-langs --save
yarn add express-langs
server.js
const exp = app = server = langs = ; app // ... , you other middleware // you other middleware ... ,; app ; server ;
methods
test exists langs
you can use const exp = app = server = langs = ; app // ... , you other middleware // you other middleware ... ,; app ; server ;
exists
methods make a relative test with langs found e.g :
langs ; // match with 'en-US'langs ; // match with 'en'langs ; // not match with 'fr'
or with an pattern e.g :
langs ; // match with 'en-US'langs ; // match with 'en' langs ; // match with 'fr'
strict test exists
e.g :
you can make a langs ; // not match with 'en-US'langs ; // match with 'en'langs ; // not match with 'fr'
getWith
method get array langs match with you support pattern
const supportLangs = langs ; // array[ langs ] // you can give an string for build an pattern e.g :const pattern = "en|fr|es" ;const supportLangs = langs ; // array[ langs ]