Try as hard as possible to detect the client's language tag ("locale") in node or the browser. Browserify and Webpack friendly!
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).
en-US
br-PT
fil-PH
- โ IE 8
- โ IE 9
- โ IE 10
- โ IE 12 (Edge)
- โ Safari 5.1+
- โ Opera (Presto & Webkit)
- โ Firefox
- โ Chrome
$ 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
>
npm install --no-optional
npm test
npm run test-bs
If we can't detect your locale, then we'll give you your money back! it's win-win!