Для документации этого модуля может быть создана страница Модуль:WDCommon/doc

require('strict')

local p = {}

local base = require('Модуль:WDBase')
p.base = base

p.P_SHORT_NAME = 'P1813'
p.P_UNIT = 'P5061'
p.P_URL_MASK = 'P1630'
p.P_NAME = 'P1476'
p.P_ABBR_ENTRY = 'P8703'
p.P_USED_BY = 'P1535'

function p.name(entity, lang)
	local name, valueLang = base.tryTextByLang(entity, p.P_NAME, lang)
	if not name then
		if lang then
			name = mw.wikibase.getLabelByLang(entity, lang)
			valueLang = lang
		end
		if not name then
			name, valueLang = mw.wikibase.getLabelWithLang(entity)
		end
	end
	return name, valueLang
end

function p.short(entity, lang)
	local short = base.textByLang(entity, p.P_SHORT_NAME, lang)
	local ok = true
	if not short then
		if lang then
			short = mw.wikibase.getLabelByLang(entity, lang)
		else
			short, lang = mw.wikibase.getLabelWithLang(entity)
		end
		ok = false
	end
	return short, lang, ok
end

function p.abbr(entity, lang)
	-- Currently there is no global property for abbreviations by languages,
	-- see [[d:Wikidata:Property proposal/abbreviation for details]]
	local abbrByLang = {
		ru = 'Q114796497',
	}
	local abbrTableEntity = abbrByLang[lang]
	local abbr = base.valueByQualifier(entity, p.P_ABBR_ENTRY, p.P_USED_BY, abbrTableEntity)
	if not abbr then
		local short, lang = p.short(entity, lang)
		return short, lang, false
	end
	return abbr, lang, true
end

function p.abbrBiblio(entity, lang)
	-- Only Russian language is supported
	local abbrByLang = {
		ru = 'Q19670003',
	}
	if not lang then
		lang = defaultLang
	end
	local abbrTableEntity = abbrByLang[lang]
	local abbr = base.valueByQualifier(entity, p.P_ABBR_ENTRY, p.P_USED_BY, abbrTableEntity)
	if not abbr then
		return p.abbr(entity, lang)
	end
	return abbr, lang, true
end

function p.unit(entity, lang)
	return base.textByLang(entity, p.P_UNIT, lang)
end

function p.urlMask(entity, lang)
	return base.tryTextByLang(entity, p.P_URL_MASK, lang)
end

return p