Detect language preference of a page or an element.
Install with component:
$ component install decanat/get-locale
Install with npm for browserify:
$ npm install decanat-get-locale
To get preferred language getLocale
checks following sources (in order):
- HTML
lang
attribute - Cookies
navigator.language
- Default, specified in config
var getLocale = require('get-locale');
getLocale(); // 'en-US'
To test with PhantomJS, run:
$ make test
The MIT License