Modulu:Wikidata/Units
Itxura
Documentation for this module may be created at Modulu:Wikidata/Units/dok
local wikidata_units = {
Q11573 = {
label = 'metro',
ucode = 'm',
},
Q41803 = {
label = 'gramo',
ucode = 'g',
},
Q5151 = {
label = 'hilabete',
plural = 'hilabete',
},
Q28390 = {
label = 'gradu sexagesimal',
plural = 'gradu sexagesimal',
ucode = 'º',
},
Q11579 = {
label = 'Kelvin',
plural = 'Kelvin',
ucode = 'K',
},
Q174728 = {
label = 'zentimetro',
plural = 'zentimetro',
ucode = 'cm',
},
Q828224 = {
label = 'kilometro',
plural = 'kilometro',
ucode = 'km',
},
Q712226 = {
label = 'kilometro koadro',
plural = 'kilometro koadro',
ucode = 'km²',
},
Q4243638 = {
label = 'kilometro kubiko',
plural = 'kilometro kubiko',
ucode = 'km³',
},
Q13147228 = {
label = 'gramo zentimetro kubikoko',
plural = 'gramo zentimetro kubikoko',
ucode = 'g/cm³',
},
Q1811 = {
label = 'unitate astronomiko',
plural = 'unitate astronomiko',
ucode = '[[Unitate astronomiko|UA]]',
},
Q25343 = {
label = 'metro koadro',
plural = 'metro koadro',
ucode = 'm²',
},
Q613726 = {
label = 'yottagramo',
plural = 'yottagramo',
ucode = 'Yg',
},
Q180892 = {
label = 'Eguzki masa',
plural = 'Eguzki masa',
ucode = 'M☉',
},
Q4220561 = {
label = 'kilometro segunduko',
plural = 'kilometro segunduko',
ucode = 'km/s',
},
Q844211 = {
label = 'kilogramo metro kubikoko',
plural = 'kilogramo metro kubiboko',
ucode = 'kg/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
local convert_default = {
Q218593 = "Q174789", -- in > mm
Q3710 = "Q174728", -- ft > cm
Q482798 = "Q11573", -- yd > m
Q253276 = "Q828224", -- mi > km
Q232291 = "Q712226", -- mi² > km²
Q128822 = "Q180154", -- nus > km/h
}
return {
getUnit = getUnit,
convert_default = convert_default
}