Coder Social home page Coder Social logo

barbagrigia / locale2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moimikey/locale2

0.0 2.0 0.0 127 KB

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

License: MIT License

JavaScript 98.47% HTML 1.53%

locale2's Introduction

locale2 Build Status

Version License 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!

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).

en-US

br-PT

fil-PH

  1. RFC 5646
  2. BCP 47

Unit tested and browser tested!

BrowserStack

  • ✓ IE 8
  • ✓ IE 9
  • ✓ IE 10
  • ✓ IE 12 (Edge)
  • ✓ Safari 5.1+
  • ✓ Opera (Presto & Webkit)
  • ✓ Firefox
  • ✓ Chrome

It works in node too!

$ 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
>

Get it!

npm install --no-optional
npm test

Browser testing (currently private)

npm run test-bs

Try it!

view on requirebin

Guaranteed!

If we can't detect your locale, then we'll give you your money back! it's win-win!

locale2's People

Contributors

moimikey avatar greenkeeperio-bot avatar

Watchers

James Cloos avatar Vlad Trukhin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.