Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moimikey/locale2
💪 Try as hard as possible to detect the client's language tag ("locale") in node or the browser. Browserify and Webpack friendly!
https://github.com/moimikey/locale2
bcp-47 dev-deps i18n internationalization iso-3166-1 l10n locale localization rfc-5646 unicode
Last synced: 2 days ago
JSON representation
💪 Try as hard as possible to detect the client's language tag ("locale") in node or the browser. Browserify and Webpack friendly!
- Host: GitHub
- URL: https://github.com/moimikey/locale2
- Owner: moimikey
- License: mit
- Created: 2015-04-18T20:47:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-17T14:31:57.000Z (about 3 years ago)
- Last Synced: 2024-11-08T08:08:34.157Z (7 days ago)
- Topics: bcp-47, dev-deps, i18n, internationalization, iso-3166-1, l10n, locale, localization, rfc-5646, unicode
- Language: JavaScript
- Homepage:
- Size: 504 KB
- Stars: 63
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# locale2 [![Build Status][travis-image]][travis-url]
[![Version][npm-version-image]][npm-version-url] [![Downloads][npm-downloads-image]][npm-downloads-url] [![Deps][npm-deps-image]][npm-deps-url] [![DevDeps][npm-devdeps-image]][npm-devdeps-url]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](https://tools.ietf.org/html/rfc5646)
1. [BCP-47](https://tools.ietf.org/html/bcp47)### Unit tested and browser tested with BrowserStack
[![BrowserStack][browserstack-logo]][browserstack-url]
**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
```sh
$ babel-node
> import locale2 from 'locale2'
> locale2
en-US
>
```### ...and pairs well with [iso3166-1](https://npmjs.org/package/iso3166-1)!
```sh
var iso3166 = require('iso3166-1')
var locale2 = require('locale2')
> iso3166.from(locale2).to3()
USA
>
```## Install
```sh
npm install --no-optional
npm test
```## Development
### Browser testing (currently private)
```sh
npm run test:bs
npm run test:bs:local
```## Try it now
[![view on requirebin](http://requirebin.com/badge.png)](http://requirebin.com/?gist=8394988344ff2514df5e)
## License
[![License][npm-license-image]][npm-license-url]
[browserstack-logo]: https://raw.githubusercontent.com/moimikey/locale2/master/assets/bs.png
[browserstack-url]: http://browserstack.com
[npm-version-url]: https://www.npmjs.com/package/locale2
[npm-version-image]: https://img.shields.io/npm/v/locale2.svg
[npm-license-url]: https://github.com/moimikey/locale2/blob/master/LICENSE
[npm-license-image]: https://img.shields.io/npm/l/locale2.svg
[npm-downloads-url]: https://www.npmjs.com/package/locale2
[npm-downloads-image]: https://img.shields.io/npm/dm/locale2.svg
[npm-deps-url]: https://david-dm.org/moimikey/locale2
[npm-deps-image]: https://img.shields.io/david/moimikey/locale2.svg
[npm-devdeps-url]: https://david-dm.org/moimikey/locale2
[npm-devdeps-image]: https://img.shields.io/david/dev/moimikey/locale2.svg
[travis-url]: https://travis-ci.org/moimikey/locale2
[travis-image]: https://travis-ci.org/moimikey/locale2.svg?branch=master