1.7.0 • Published 6 years ago

browser-language v1.7.0

Weekly downloads
25
License
GPL-3.0
Repository
github
Last release
6 years ago

browser-language

NPM version Linux Status Windows Status Dependency Status Coveralls

Grab browser language and store min value on cookie for nodejs. If browser['Accept-Language'] = it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4, store it on cookie, otherwise, if language is not available, store default language en

Installation

Install through NPM

npm install browser-language

or

git clone git://github.com/hex7c0/browser-language.git

API

Normal use inside expressjs project

var language = require('browser-language');
var app = require('express')();

app.use(language());

Signed use inside expressjs project

var language = require('browser-language');
var app = require('express')();
var cookie = require('cookie-parser');

app.use(cookie('foo'));
app.use(language({
    dictionary: {
        _default: 'en',
        en: 'en'
    },
    cookie: 'new_cookie_name',
    signed: true
}));

Check Cookie options

language(options)

options

  • dictionary - Object Accepted language
  • _default - String The dafault value, if request from client cannot be evaluated
  • en - String Set cookie with 'en' value
  • it - String Set cookie with 'it' value
  • .. - String Set cookie with '..' value
  • domain - String Domain of cookie (default "null")
  • cookie - String Name of cookie (default "lang")
  • path - String Path of cookie (default "/")
  • maxAge - Number Age of cookie in millisecond (default "1 year")
  • httpOnly - Boolean Flag for http only cookie (default "false")
  • secure - Boolean Flag for using cookie over TLS/SSL (default "false")
  • signed - Boolean Will use the secret passed to cookieParser(secret) to sign the value (default "false")
  • encryption - Object Configuration for cookie-encryption (defaut "deactivated")

dictionary object with correct value to be added, otherwise using a default dictionary inside ./lib/dictionary.js

Examples

Take a look at my examples

License GPLv3

1.7.0

6 years ago

1.6.0

7 years ago

1.5.0

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.12

9 years ago

1.2.11

10 years ago

1.2.10

10 years ago

1.2.9

10 years ago

1.2.8

10 years ago

1.2.7

10 years ago

1.2.6

10 years ago

1.2.5

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago