Module:Wikidata/Units

Si Wikipedia, tasanayt tilellit.
Jump to navigation Jump to search

Documentation for this module may be created at Module:Wikidata/Units/doc

local wikidata_units = {
	Q11573 = {
		label = 'metro',
		ucode = 'm',
		},
	Q5151 = {
		label = 'hilabete',
		plural = 'hilabete',
		},
	Q174728 = {
		label = 'zentimetro',
		plural = 'zentimetro',
		ucode = 'cm',
		},
	Q828224 = {
		label = 'kilometro',
		plural = 'kilometro',
		ucode = 'km',
		},
	Q712226 = {
		label = 'kilometro koadro',
		plural = 'kilometro koadro',
		ucode = 'km²',
		},
Q25343 = {
		label = 'metro koadro',
		plural = 'metro koadro',
		ucode = 'm²',
		},
	}

local function getUnit(amount, label, unitID, code)
	local id_data = wikidata_units[unitID] or {}
	local unit_text = ''
	if code then
		unit_text = id_data.ucode or id_data.label or label
	elseif amount == "1" then
		unit_text = id_data.label or label
	else
		unit_text = id_data.plural or label
	end
	return unit_text
end

return {getUnit = getUnit}