Gathering detailed insights and metrics for wikidata-lang
Gathering detailed insights and metrics for wikidata-lang
Gathering detailed insights and metrics for wikidata-lang
Gathering detailed insights and metrics for wikidata-lang
npm install wikidata-lang
Typescript
Module System
Node Version
NPM Version
78.9
Supply Chain
99.5
Quality
76.1
Maintenance
100
Vulnerability
100
License
JavaScript (97.84%)
Shell (2.16%)
Total Downloads
445,893
Last Day
37
Last Week
121
Last Month
630
Last Year
12,626
16 Stars
66 Commits
5 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
4.1.2
Package Id
wikidata-lang@4.1.2
Unpacked Size
914.21 kB
Size
246.74 kB
File Count
73
NPM Version
8.3.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last day
0%
37
Compared to previous day
Last week
-42.1%
121
Compared to previous week
Last month
54.4%
630
Compared to previous month
Last year
-91.7%
12,626
Compared to previous year
A database of languages and their wikidata id, Wikimedia language code, ISO 639-1, ISO 639-2, ISO 639-3, and ISO 639-6 codes. A database of languages and their Wikidata id, Wikimedia language code, ISO 639-1, ISO 639-2, ISO 639-3, ISO 639-6 codes
This database is based on the result of a SPARQL query executed on query.wikidata.org, so the data is as good as Wikidata is: in case of an error, please update Wikidata and request an update of this database in the issues.
For each language, the data object looks like this:
1{ 2 wd: 'Q8798', // https://wikidata.org/entity/Q8798 3 label: 'Ukrainian', // English label 4 native: 'українська мова', // P1705 5 wmCode: [ 'uk' ], // P424 6 iso6391: [ 'uk' ], // P218 7 iso6392: [ 'ukr' ], // P219 8 iso6393: [ 'ukr' ] // P220 9 // iso6396 value (P221) missing for Q8798 10}
From a terminal, in your project directory, run:
1npm install wikidata-lang
In your JS code:
1// languages indexed by Wikidata id is the default 2const languagesByWdId = require('wikidata-lang') 3 4// For indexes by other available codes, require the desired module: 5const languagesByIso6391Code = require('wikidata-lang/indexes/by_iso_639_1_code') 6const languagesByIso6392Code = require('wikidata-lang/indexes/by_iso_639_2_code') 7const languagesByIso6393Code = require('wikidata-lang/indexes/by_iso_639_3_code') 8const languagesByIso6396Code = require('wikidata-lang/indexes/by_iso_639_6_code') 9const languagesByWmCode = require('wikidata-lang/indexes/by_wm_code') 10// Note that you can also use an index regrouping all of the above 11const languagesByAnyCode = require('wikidata-lang/indexes/by_any_code') 12 13// The Wikidata id index returns single language data objects 14languagesByWdId.Q8798 15// => { "code": "uk", "label": "Ukrainian", "native": "Українська", "wd": "Q8798" } 16 17// while indexes by code always return arrays of language data objects 18// to account for edge cases where several Wikidata languages items share a common code. 19languagesByIso6391Code.uk[0] 20// => { "code": "uk", "label": "Ukrainian", "native": "Українська", "wd": "Q8798" }
Conversion mappings can be build from the language data objects described above, but you can also use the pre-built ones:
1const wdIdByWmCode = require('wikidata-lang/mappings/wd_id_by_wm_code.json') 2wdIdByWmCode['zh-min-nan'] // => 'Q36495' 3 4const wdIdByIso6391Code = require('wikidata-lang/mappings/wd_id_by_iso_639_1_code.json') 5wdIdByIso6391Code['cr'] // => 'Q33390' 6 7const wdIdByIso6392Code = require('wikidata-lang/mappings/wd_id_by_iso_639_2_code.json') 8wdIdByIso6392Code['kzu'] // => 'Q6380723' 9 10const wdIdByIso6393Code = require('wikidata-lang/mappings/wd_id_by_iso_639_3_code.json') 11wdIdByIso6393Code['acc'] // => 'Q16110361' 12 13const wdIdByIso6396Code = require('wikidata-lang/mappings/wd_id_by_iso_639_6_code.json') 14wdIdByIso6396Code['jah'] // => 'Q2742661' 15 16const wmCodeByWdId = require('wikidata-lang/mappings/wm_code_by_wd_id.json') 17wmCodeByWdId['Q32762'] // => 'fiu-vro' 18 19// This one seems useless, as ISO 639-1 seem to always be equivalent to their corresponding Wikimedia language code 20const wmCodeByIso6391Code = require('wikidata-lang/mappings/wm_code_by_iso_639_1_code.json') 21wmCodeByIso6391Code['id'] // => 'id' 22 23const wmCodeByIso6392Code = require('wikidata-lang/mappings/wm_code_by_iso_639_2_code.json') 24wmCodeByIso6391Code['zza'] // => 'diq' 25 26const wmCodeByIso6393Code = require('wikidata-lang/mappings/wm_code_by_iso_639_3_code.json') 27wmCodeByIso6391Code['yue'] // => 'zh-yue' 28 29const wmCodeByIso6396Code = require('wikidata-lang/mappings/wm_code_by_iso_639_6_code.json') 30wmCodeByIso6391Code['yyef'] // => 'zh-yue' 31 32// etc.
See the mappings
folder for a full list of available mappings.
NB: When several values are available for a given key, no value is added to the mapping for that key. It is added instead to the mappings/x_by_x.multiple_values.json
file.
For instance, in ISO 639-2, both ell
and gre
are mapped to el
in ISO 639-1 (also true for Wikimedia language codes)
See how we use it in Inventaire
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
4 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More