an index of 183 languages accessible either by their 2-letters language code or Wikidata Qid
Switch branches/tags
Clone or download
Pull request Compare This branch is 27 commits ahead of maxlath:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


An index of 183 languages accessible either by their 2-letters language code or Wikidata Qid.

For each language, it returns an object that looks like this:

  "code": "uk",
  "label": "Ukrainian",
  "native": "Українська",
  "wd": "Q8798"

where wd stands for wikidata and Q8798 for



via npm

in your terminal

npm install wikidata-lang --save

in your JS code

var wdLang = require('wikidata-lang')


the index can be accessed in two ways:

  • by language code
// => { "code": "uk", "label": "Ukrainian", "native": "Українська", "wd": "Q8798" }
  • by wikidata id
// => { "code": "uk", "label": "Ukrainian", "native": "Українська", "wd": "Q8798" }

But why?!?

When you deal with Wikidata entities from different countries (such as books or authors in the case of inventaire), you often find entities for which there is no label in the initialy desired language. To decide which language to use as fallback, you may wish to use the entities original language properties:

P103: native language (for humans/authors)
P364: original language of work (for books)

Those properties use entities as values, and that's where this lib becomes useful: you want to answer the question what is the 2 letters language code associated with this original language Qxxx ? (ex: Q188, Q1321, etc.) without having to do extra requests.

var myLangCode = 'fr'
var originalLang = 'Q1321'
var originalLangCode = wdLang.byWdId[originalLang]
var label = entity.labels[myLangCode] || entity.labels[originalLangCode] || entity.labels['en']

Example: use in inventaire

Let's request an entity that miss labels in English and French, and request it as a French speaking user:

see the code


2-letters language codes are Wikimedia language codes, which fits mostly ISO 639-1 codes (out of some exceptions?)