{"name":"language-tags","version":"1.0.6","implements":["CommonJS/Modules/1.0"],"description":"Work with IANA language tags.","main":"lib/index.js","homepage":"https://github.com/mattcg/language-tags","author":{"name":"Matthew Caruana Galizia","email":"mattcg@gmail.com"},"repository":{"type":"git","url":"git://github.com/mattcg/language-tags.git"},"bugs":{"url":"https://github.com/mattcg/language-tags/issues"},"license":"MIT","scripts":{"test":"make test"},"keywords":["iana","bcp47","subtags","rfc5646","m17n","multilingualization"],"dependencies":{"language-subtag-registry":"^0.3.20"},"devDependencies":{"mocha":"~6.2.0","istanbul":"~0.4.2","coveralls":"~3.0.5"},"gitHead":"b976a2ac29419bb8572b0f4bfc58d04fc34b68c5","_id":"language-tags@1.0.6","_nodeVersion":"19.1.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-HNkaCgM8wZgE/BZACeotAAgpL9FUjEnhgF0FVQMIgH//zqTPreLYMb3rWYkYAqPoF75Jwuycp1da7uz66cfFQg==","shasum":"c087cc42cd92eb71f0925e9e271d4f8be5a93430","tarball":"http://registry-npm.ywwl.com/language-tags/download/language-tags-1.0.6.tgz","fileCount":5,"unpackedSize":24182,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFuJXc45g9haXumovR75LM+AByXNqxCZ40ddMKyUcrUnAiEAifjr4qMMrZ0oWgE48jRpAEYoRnJPd4jAiSbO7FNK3JA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiPSTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpBGw/+M4cd5ofPMs2gXkkPd2sVF3OAkd7/+EeRWdLbcGOO00SYlCjd\r\nOH7qypYSZF611yKg1LH7+peFZeGSk5cmhDDIKWBojALPq/7BgEwwMTRTnRom\r\nyefUk9asyoe+DLxYuff3CS7XKoZWDe0gV5ZBrIcx7pJu9XDfHoHl9tX1qorw\r\nbZMMyhLK7p1gWLg1r9d45LynokxnXVZajRQrcj6WoVp6UZknh1pHTqAQYcDo\r\n8gLV94ub6AxW/OW23aq479A8HoTNsbmlsg4o/eX65JvoXZHJe0xjLKuQ9yy7\r\ncfsE9dyLw9pkm8DGr84c9sP5MQVrzHejjBRzIWLC0ZgHW8GEU3cAVM3C94QL\r\nu8ycJVOj13otPAV5V8pNMwOjWHpXOFcuQ2aa1TViLCmzHegE0CweQPKvdspa\r\nP053FKnBQbbdRiUl9gRXVdEh9Oy1ur8X2cRTMJxzLqJaj9Ga4R2l0ON34/yL\r\ntNsiMzqpXrytG7gsj/BYLdzZz9NOVhCYbyIiGQfeTPTsNsD5iDIswPcSsJHe\r\nXfKlYjGfNA5uRrgLdue7mG1S/KUqOuHnLZyrsBgZ3DJBoWxlITwZlVe6nUyA\r\nITtfBaUJz49EaIO32q6F8gaQAkMcKhg5af7O1huZ9Skva2KA/VhjCN771ulr\r\nPWomG4qJkL9u+3jU/kzD+UjEYACSDBf82DA=\r\n=jU2y\r\n-----END PGP SIGNATURE-----\r\n","size":7014,"noattachment":false,"key":"/language-tags/-/language-tags-1.0.6.tgz"},"_npmUser":{"name":"mcg","email":"mattcg@gmail.com"},"directories":{},"maintainers":[{"name":"mcg","email":"mattcg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/language-tags_1.0.6_1669919890952_0.25886821624937584"},"_hasShrinkwrap":false,"readme":"# IANA Language Tags for JavaScript #\n\n[![Build Status](https://travis-ci.org/mattcg/language-tags.png?branch=master)](https://travis-ci.org/mattcg/language-tags)\n[![Coverage Status](https://coveralls.io/repos/mattcg/language-tags/badge.png)](https://coveralls.io/r/mattcg/language-tags)\n\nBased on [BCP 47](https://www.rfc-editor.org/info/bcp47) ([RFC 5646](https://www.rfc-editor.org/rfc/rfc5646.html)) and the latest [IANA language subtag registry](http://www.iana.org/assignments/language-subtag-registry).\n\nThis project will be updated as the standards change.\n\n## JSON data ##\n\nSee the [language-subtag-registry](https://github.com/mattcg/language-subtag-registry) project for the underlying JSON data.\n\n## API ##\n\n```js\nvar tags = require('language-tags')\n```\n\nNote that all lookups and checks for tags and subtags are case insensitive. For formatting according to common conventions, see `tag.format`.\n\n### tags(tag) ###\n\nCheck whether a hyphen-separated tag is valid and well-formed. Always returns a `Tag`, which can be checked using the `valid` method.\n\n### tags.check(tag) ###\n\nShortcut for `tags(tag).valid()`. Return `true` if the tag is valid, `false` otherwise. For meaningful error output see `tag.errors()`.\n\n### tags.subtags(subtag), tags.subtags(subtags) ###\n\nLook up one or more subtags. Returns an array of `Subtag` objects. Returns an empty array if all of the subtags are non-existent.\n\nCalling `tags.subtags('mt')` will return an array with two `Subtag` objects: one for Malta (the 'region' type subtag) and one for Maltese (the 'language' type subtag).\n\n```\n> tags.subtags('mt');\n[Subtag, Subtag]\n> tags.subtags('bumblebee');\n[]\n```\n\nTo get or check a single subtag by type use `tags.language(subtag)`, `tags.region(subtag)` or `tags.type(subtag, type)`.\n\n### tags.filter(subtags) ###\n\nThe opposite of `tags.subtags(subtags)`. Returns an array of codes that are not registered subtags, otherwise returns an empty array.\n\n```\n> tags.filter(['en', 'Aargh']);\n['Aargh']\n```\n\n### tags.search(description, [all]) ###\n\nSearch for tags and subtags by description. Supports either a RegExp object or a string for `description`. Returns an array of `Subtag` and `Tag` objects or an empty array if no results were found.\n\nNote that `Tag` objects in the results represent 'grandfathered' or 'redundant' tags. These are excluded by default. Set the `all` parameter to `true` to include them.\n\nSearch is case-insensitive if `description` is a string.\n\n### tags.languages(macrolanguage) ###\n\nReturns an array of `Subtag` objects representing all the 'language' type subtags belonging to the given 'macrolanguage' type subtag.\n\nThrows an error if `macrolanguage` is not a macrolanguage.\n\n```\n> tags.languages('zh');\n[Subtag, Subtag...]\n> tags.languages('en');\nError: 'en' is not a valid macrolanguage.\n```\n\n### tags.language(subtag) ###\n\nConvenience method to get a single 'language' type subtag. Can be used to validate an input value as a language subtag. Returns a `Subtag` object or `null`.\n\n```\n> tags.language('en');\nSubtag\n> tags.language('us');\nnull\n```\n\n### tags.region(subtag) ###\n\nAs above, but with 'region' type subtags.\n\n```\n> tags.region('mt');\nSubtag\n> tags.region('en');\nnull\n```\n\n### tags.type(subtag, type) ###\n\nGet a subtag by type. Returns the subtag matching `type` as a `Subtag` object otherwise returns `null`.\n\nA `type` consists of one of the following strings: 'language', 'extlang', 'script', 'region' or 'variant'. To get a 'grandfathered' or 'redundant' type tag use `tags(tag)`.\n\n```\n> tags.type('zh', 'macrolanguage');\nSubtag\n> tags.type('zh', 'script');\nnull\n```\n\n### tags.date() ###\n\nReturns the file date for the underlying data, as a string.\n\n```\n> tags.date();\n'2004-06-28'\n```\n\n### Subtag ###\n\n#### subtag.type() ####\n\nGet the subtag type (either 'language', 'extlang', 'script', 'region' or 'variant'). See [RFC 5646 section 2.2](http://tools.ietf.org/html/rfc5646#section-2.2) for type definitions.\n\n#### subtag.descriptions() ####\n\nReturns an array of description strings (a subtag may have more than one description).\n\n```\n> tags.language('ro').descriptions();\n['Romanian', 'Moldavian', 'Moldovan']\n```\n\n#### subtag.preferred() ####\n\nReturns a preferred subtag as a `Subtag` object if the subtag is deprecated. For example, `ro` is preferred over deprecated `mo`.\n\n```\n> tags.language('mo').preferred();\nSubtag\n```\n\n#### subtag.script() ####\n\nFor subtags of type 'language' or 'extlang', returns a `Subtag` object representing the language's default script. See [RFC 5646 section 3.1.9](http://tools.ietf.org/html/rfc5646#section-3.1.9) for a definition of 'Suppress-Script'.\n\n#### subtag.scope() ####\n\nReturns the subtag scope as a string, or `null` if the subtag has no scope.\n\nTip: if the subtag represents a macrolanguage, you can use `tags.languages(macrolanguage)` to get a list of all the macrolanguage's individual languages.\n\n```\n> tags.language('zh').scope();\n'macrolanguage'\n> tags.language('nah').scope();\n'collection'\n```\n\n#### subtag.deprecated() ####\n\nReturns a date string reflecting the deprecation date if the subtag is deprecated, otherwise returns `null`.\n\n```\n> tags.language('ja').deprecated();\n'2008-11-22'\n```\n\n#### subtag.added() ####\n\nReturns a date string reflecting the date the subtag was added to the registry.\n\n```\n> tags.language('ja').added();\n'2005-10-16'\n```\n\n#### subtag.comments() ####\n\nReturns an array of comments, if any, otherwise returns an empty array.\n\n```\n> tags.language('nmf').comments();\n['see ntx']\n```\n\n#### subtag.format() ####\n\nReturn the subtag code formatted according to the case conventions defined in [RFC 5646 section 2.1.1](http://tools.ietf.org/html/rfc5646#section-2.1.1).\n\n- language codes are made lowercase ('mn' for Mongolian)\n- script codes are made lowercase with the initial letter capitalized ('Cyrl' for Cyrillic)\n- country codes are capitalized ('MN' for Mongolia)\n\n### Tag ###\n\n#### tag.preferred() ####\n\nIf the tag is listed as 'deprecated' or 'redundant' it might have a preferred value. This method returns a `Tag` object if so.\n\n```\n> tags('zh-cmn-Hant').preferred();\nTag\n```\n\n#### tag.type() ####\n\nReturns `grandfathered` if the tag is grandfathered, `redundant` if the tag is redundant, and `tag` if neither. For a definition of grandfathered and redundant tags, see [RFC 5646 section 2.2.8](http://tools.ietf.org/html/rfc5646#section-2.2.8).\n\n#### tag.subtags() ####\n\nReturns an array of subtags making up the tag, as `Subtag` objects.\n\n#### tag.language(), tag.region(), tag.script() ####\n\nShortcuts for `tag.find('language')`, `tag.find('region')` and `tag.find('script')`.\n\n#### tag.find(type) ####\n\nFind a subtag of the given type from those making up the tag.\n\n#### tag.valid() ####\n\nReturns `true` if the tag is valid, `false` otherwise.\n\n#### tag.errors() ####\n\nReturns an array of `Error` objects if the tag is invalid. The `message` property of each is readable and helpful enough for UI output. The `code` property can be checked against the `Tag.ERR_*` constants. Each error will also have either a `subtag` or `tag` property with the code of the offending tag.\n\n#### tag.format() ####\n\nFormat a tag according to the case conventions defined in [RFC 5646 section 2.1.1](http://tools.ietf.org/html/rfc5646#section-2.1.1).\n\n```\n> tags('en-gb').format();\n'en-GB'\n```\n\n#### tag.deprecated() ####\n\nFor grandfathered or redundant tags, returns a date string reflecting the deprecation date if the tag is deprecated.\n\n```\n> tags('zh-cmn-Hant').deprecated();\n'2009-07-29'\n```\n\n#### tag.added() ####\n\nFor grandfathered or redundant tags, returns a date string reflecting the date the tag was added to the registry.\n\n#### tag.descriptions() ####\n\nReturns an array of tag descriptions for grandfathered or redundant tags, otherwise returns an empty array.\n\n## Resources ##\n\n- [Python version by the Flanders Heritage Agency](https://github.com/OnroerendErfgoed/language-tags)\n- [Language Subtag Lookup tool by Richard Ishida](http://rishida.net/utils/subtags/)\n- [W3C Internationalization Checker](http://validator.w3.org/i18n-checker/)\n- [RFC 5646](http://tools.ietf.org/html/rfc5646)\n\n## Credits and collaboration ##\n\nCopyright (c) 2013, [Matthew Caruana Galizia](http://twitter.com/mcaruanagalizia).\n\nThe software part of this project is licensed under an [MIT licence](http://mattcg.mit-license.org/).\n\nComments, feedback and suggestions are welcome. Please feel free to raise an issue or pull request. Enjoy.\n","publish_time":1669919891223,"_cnpm_publish_time":1669919891223,"dist-tags":{"latest":"2.1.0"}}