Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
language-subtag-registry
Advanced tools
Full BCP 47 language subtag data from the official IANA repository, in JSON format with multiple indices.
The language-subtag-registry npm package provides an interface to access and manipulate data from the IANA Language Subtag Registry. This registry contains codes that are used to identify human languages, scripts, countries, and variants. The package allows for searching, validating, and parsing these codes, making it useful for applications that need to handle language tags according to the IETF BCP 47 standard.
Searching for language subtags
This feature allows users to search the registry for specific subtags. In the code sample, the search function is used to find entries related to the 'en' subtag, which typically corresponds to English.
const { search } = require('language-subtag-registry');
const results = search('en');
console.log(results);
Validating language subtags
This feature enables the validation of language subtags to ensure they conform to the IETF BCP 47 standard. The code sample demonstrates validating the 'en-US' language tag, which represents English as used in the United States.
const { validate } = require('language-subtag-registry');
const isValid = validate('en-US');
console.log(isValid);
Parsing language subtags
This feature provides the ability to parse complex language tags into their constituent parts, such as language, script, and region. The code sample parses 'zh-Hant-HK', which represents Chinese written in the Traditional script as used in Hong Kong.
const { parse } = require('language-subtag-registry');
const parsed = parse('zh-Hant-HK');
console.log(parsed);
Similar to language-subtag-registry, the bcp-47 package provides tools for parsing and validating BCP 47 language tags. However, it focuses more on the syntax of the tags rather than providing access to the registry data itself.
The iso-639-1 package offers functionality for working with ISO 639-1 language codes, including getting names of languages and converting between codes and names. It is similar in that it deals with language codes, but it is limited to the ISO 639-1 standard and does not cover scripts or regions.
This package is designed to work with ISO 3166-1 country codes, providing functionality to search, validate, and get information about countries. While it deals with a different aspect of language tags (the region subtag), it offers similar utility in terms of validating and parsing codes related to geographic regions.
IANA's official repository is in record-jar format and is hard to parse. This project provides neatly organized JSON files representing that data.
See lib/data/
for all the JSON files available. The registry.json
file contains all records in a flat array and meta.json
contains its metadata. There's a separate JSON file for each 'scope' (e.g. macrolanguage.json
) and 'type' (e.g. language.json
). These files contain JSON objects keyed by tag or subtag and with the index integer for the corresponding entry in registry.json
as a value. This makes lookups fast.
This project will be updated as the registry changes. Non-breaking updates will result in the patch version number being bumped.
Run make update
to force an update from the latest official IANA-hosted version. The registry file format is converted to JSON automatically and the files in data/
are updated.
If there are changes, please make a pull request.
See language-tags for a Javascript API.
Update scripts copyright (c) 2013, Matthew Caruana Galizia and licensed under and MIT license.
The JSON database is licensed an Open Data Commons Attribution License (ODC-BY).
Comments, feedback and suggestions are welcome. Please feel free to raise an issue or pull request. Enjoy.
FAQs
Full BCP 47 language subtag data from the official IANA repository, in JSON format with multiple indices.
The npm package language-subtag-registry receives a total of 5,383,967 weekly downloads. As such, language-subtag-registry popularity was classified as popular.
We found that language-subtag-registry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.