locale2
Try as hard as possible to get that browser locale.
Last updated 9 years ago by moimikey .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install locale2 
SYNC missed versions from official npm registry.

locale2 Build Status

Version Downloads Deps DevDeps

Try as hard as possible to detect the client's language tag ("locale") in node or the browser. Browserify and Webpack friendly!

About Language Tags, Locale, RFC-5646 and BCP-47

In 2009, IETF published RFC-5646, "Tags for Identifying Languages," in which "...describes the structure, content, construction, and semantics of language tags for use in cases where it is desirable to indicate the language used in an information object."

A language tag is composed from a sequence of one or more "subtags", each of which refines or narrows the range of language identified by the overall tag. Subtags, in turn, are a sequence of alphanumeric characters (letters and digits), distinguished and separated from other subtags in a tag by a hyphen ("-", [Unicode] U+002D).

References:

  1. RFC-5646
  2. BCP-47

Unit tested and browser tested with BrowserStack

BrowserStack

Tested successfully on:

✓ IE 8 ✓ IE 9 ✓ IE 10 ✓ IE 11 ✓ IE 12 (Edge)

✓ Safari 5.1+

✓ Opera (Presto, Webkit, Blink)

✓ Firefox

✓ Chrome

Node support

$ babel-node
> import locale2 from 'locale2'
> locale2
en-US
>

...and pairs well with iso3166-1!

var iso3166 = require('iso3166-1')
var locale2 = require('locale2')
> iso3166.from(locale2).to3()
USA
>

Install

npm install --no-optional
npm test

Development

Browser testing (currently private)

npm run test:bs
npm run test:bs:local

Try it now

view on requirebin

License

License

Current Tags

  • 2.3.1                                ...           latest (6 years ago)

20 Versions

  • 2.3.1                                ...           6 years ago
  • 2.2.1                                ...           6 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.4                                ...           7 years ago
  • 2.1.2                                ...           8 years ago
  • 2.1.1                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.5                                ...           9 years ago
  • 2.0.4                                ...           9 years ago
  • 2.0.3                                ...           9 years ago
  • 2.0.2                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.3-beta                                ...           10 years ago
  • 0.0.2-beta                                ...           10 years ago
  • 0.0.1-beta                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE