RFC 5646 Language Tag Implementation
Basic Language Tag handling. Does not attempt to do validation against
the registry. If you need a more complete implementation, look at
https://www.npmjs.com/package/language-tags by https://www.npmjs.com/~mcg
License: Public Domain
Installation
npm install rfc5646
Use
var LanguageTag = require('rfc5646');
var tag = LanguageTag('en-Latn-US');
console.log(tag.language);
console.log(tag.script);
console.log(tag.region);
console.log(tag.variant);
console.log(tag.minimal.toString());
console.log(tag == 'en-Latn-US');
console.log(tag.matches('en-*'));
console.log(tag.minimal.suitableFor('en-US'));
console.log(tag.truncate().toString());
console.log(tag.truncate({script:false}).toString());
tag.forEach(function(subtag) {
console.log(subtag.toString());
});
tag = LanguageTag('en-US-a-abc-b-xyz-x-123');
console.log(tag.extensions.a.toString());
console.log(tag.extensions.b.toString());
console.log(tag.privateuse.toString());