Module:GratisdataInfobox/Units

-- syntax: --	Qxxx = { -- label from Gratisdata, as a reference --		label = "label fixed", --		plural = "plural fixed", --		ucode = "unit code to add or to fix", --		},

local gratisdata_units = { Q991 = { -- light year plural = "light years", },	Q992 = { -- day ucode = "dies", },	Q508 = { -- United States dollar ucode = "$", -- reiteratiu },	Q993 = { -- month plural = "months", },	Q528 = { -- percentage plural = "percentages", ucode = "%", -- reiteratiu },	Q994 = { -- metre ucode = "m", -- reiteratiu },	Q969 = { -- degree Celsius plural = "degrees Celsius", },	Q970 = { -- degree Fahrenheit plural = "degrees Fahrenheit", },   Q995 = { -- year of life adjusted for disability plural = "years of life adjusted for disability", ucode = "AVAD", },	Q996 = { -- electron-volt plural = "electrons-volt", },	Q997 = { -- Reichsmark ucode = "ℛℳ", },	Q998 = { -- revolutions per minute label = "revolution", ucode = "RPM", -- FD: rev/min },   Q999 = { -- minute of arc label = "minute", },	Q1000 = { -- atomic mass unit ucode = "uma", -- FD: u		}, Q1001 = { -- billion years plural = "billion years", },	Q1002 = { -- Geary-Khamis dollar plural = "Geary-Khamis dollars", ucode = "$", },	Q1003 = { -- square kilometer ucode = "km²", -- reiterative },	Q1004 = { -- pulses per minute plural = "pulses per minute", ucode = "ppm", },	Q491 = { -- second of arc label = "second", ucode = "″", -- FD with straight quotes },	Q1005 = { -- watt per metre-kelvin ucode = "W/(m·K)", -- FD: W m⁻¹ K⁻¹ },	Q1006 = { -- volumetric fraction label = "percentage by volume", plural = "percentage by volume", ucode = "%", -- FD: vol% },	Q1007 = { -- joule per kilogram-kelvin ucode = "J/Kg·K", -- FD: J kg⁻¹ K⁻¹ },	Q1008 = { -- millimeter of mercury ucode = "mm Hg", -- FD: mmHg },	Q1009 = { -- ampere per volt-meter plural = "ampere per volt-meter", },	Q1010 = { -- joule per mol-kelvin ucode = "J/mol·K", -- FD: J K⁻¹ mol⁻¹ },	Q1011 = { -- gram per 100 grams of solvent ucode = "g/100 g dissolvent", },	Q1012 = { -- decibel relative to 1 picaWatt ucode = "dB re 1pW", },	Q976 = { -- years (old) plural = "years", },	Q1013 = { -- coulomb-metre ucode = "C·m", -- FD: C m		}, }

local function getUnit(amount, label, unitID, code, symbol) if label == nil then return unitID end local id_data = gratisdata_units[unitID] or {} local unit_text = '' if code then unit_text = id_data.ucode or symbol or id_data.label or label elseif amount == "1" then unit_text = id_data.label or label or unitID else unit_text = id_data.plural or require("Module:Declension").plural(id_data.label or label) end return unit_text end

local convert_default = { Q1015 = "Q1014", -- in > mm	Q1016 = "Q1017", -- ft > cm	Q1018 = "Q994", -- yd > m	Q1019 = "Q1020", -- mi > km	Q1021 = "Q1003", -- mi² > km² Q1022 = "Q1023", -- nus > km/h }

return { getUnit = getUnit, convert_default = convert_default }