এই মডিউলের জন্য মডিউল:number list/data/it/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {numbers = {}}

local m_numutils = require("Module:number list/utils")
local power_of = m_numutils.power_of

local numbers = export.numbers

local rfind = mw.ustring.find
local rsubn = mw.ustring.gsub

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

numbers[0] = {
	cardinal = "zero",
	ordinal = "zeresimo",
	ordinal_abbr = "0º",
	adverbial = "[[zero]] [[volta|volte]]",
	collective = "nessuno",
	wplink = "0 (numero)",
}

numbers[1] = {
	cardinal = {"uno", "un"},
	ordinal = "primo",
	ordinal_abbr = "1º",
	adverbial = "[[una]] [[volta]]",
	multiplier = "singolo",
	distributive = "singolarmente",
	wplink = "1 (numero)",
}

numbers[2] = {
	cardinal = "due",
	ordinal = "secondo",
	ordinal_abbr = "2º",
	adverbial = "[[due]] [[volta|volte]]",
	multiplier = {"doppio", "duplice"},
	distributive = "doppiamente",
	collective = {"entrambi", "[[tutti e]] [[due]]"},
	fractional = "mezzo",
	wplink = "2 (numero)",
}

-- From 3 to 10, we automatically generate the ordinal abbreviation, adverbial, collective, fractional and wplink entries.
numbers[3] = {
	cardinal = "tre",
	ordinal = "terzo",
	multiplier = {"triplo", "triplice"},
}

numbers[4] = {
	cardinal = "quattro",
	ordinal = "quarto",
	multiplier = "quadruplo",
}

numbers[5] = {
	cardinal = "cinque",
	ordinal = "quinto",
	multiplier = "quintuplo",
}

numbers[6] = {
	cardinal = "sei",
	ordinal = "sesto",
	multiplier = "sestuplo",
}

numbers[7] = {
	cardinal = "sette",
	ordinal = "settimo",
	multiplier = "settuplo",
}

numbers[8] = {
	cardinal = "otto",
	ordinal = "ottavo",
	multiplier = "ottuplo",
}

numbers[9] = {
	cardinal = "nove",
	ordinal = "nono",
	multiplier = "nonuplo",
}

numbers[10] = {
	cardinal = "dieci",
	ordinal = "decimo",
	multiplier = "decuplo",
}

for i = 3, 10 do
	local cardinal = numbers[i].cardinal
	numbers[i].ordinal_abbr = i .. "º"
	numbers[i].adverbial = ("[[%s]] [[volta|volte]]"):format(cardinal)
	numbers[i].collective = ("[[tutti e]] [[%s]]"):format(cardinal)
	numbers[i].fractional = numbers[i].ordinal
	numbers[i].wplink = ("%s (numero)"):format(i)
end

local function add_ordinal_suffix(term)
	if type(term) == "table" then
		local ordinals = {}
		for _, item in ipairs(term) do
			table.insert(ordinals, add_ordinal_suffix(item))
		end
		return ordinals
	end
	if rfind(term, "tre$") or rfind(term, "sei$") then
		return term .. "esimo"
	elseif rfind(term, "tré$") then
		return rsub(term, "tré$", "treesimo")
	elseif rfind(term, "dieci$") then
		return rsub(term, "dieci$", "decimo")
	elseif rfind(term, "mila$") then
		return rsub(term, "mila$", "millesimo")
	else
		return rsub(term, "[aeiou]$", "") .. "esimo"
	end
end

local function make_number(num, cardinal, ordinal, wplink)
	local numstr = m_numutils.format_fixed(num)
	numbers[num] = {
		cardinal = cardinal,
		ordinal = ordinal or add_ordinal_suffix(cardinal),
		ordinal_abbr = #numstr < 10 and m_numutils.add_thousands_separator(numstr, ".") .. "º" or nil,
		wplink = wplink or type(num) == "number" and num <= 2000 and num .. " (numero)" or nil,
	}
end

-- Generate 11 through 19.
for i, teen in ipairs { "undici", "dodici", "tredici", "quattordici", "quindici", "sedici",
	"diciassette", "diciotto", "diciannove", } do
	make_number(i + 10, teen)
end

-- Generate 20 through 99.
for i, tens_cardinal in ipairs {
	"venti", "trenta", "quaranta", "cinquanta", "sessanta",
	"settanta", "ottanta", "novanta",
} do
	local tens = (i + 1) * 10
	make_number(tens, tens_cardinal)
	for ones = 1, 9 do
		local suffix = ones == 3 and "tré" or numbers[ones].cardinal
		if type(suffix) == "table" then
			suffix = suffix[1] -- {"uno", "un"}
		end

		local cardinal =
			(suffix:find "^[aeiou]" and tens_cardinal:gsub("%f[aeiou][aeiou]$", "")
				or tens_cardinal)
			.. suffix
		make_number(tens + ones, cardinal)
	end
end

-- Generate 100 through 108.
for i, hundred_item in ipairs {
	"cento",
	{"centouno", "centuno"},
	"centodue",
	{"centotré", "centotre"},
	"centoquattro",
	"centocinque",
	"centosei",
	"centosette",
	{"centootto", "centotto"},
} do
	make_number(i + 99, hundred_item)
end

-- Generate 109 through 119.
for i = 109, 119 do
	local base = i - 100
	local cardinal = "cento" .. numbers[base].cardinal
	make_number(i, cardinal)
end

-- Generate 120 through 190 by 10.
for i = 120, 190, 10 do
	local base = i - 100
	local cardinal = i == 180 and "centottanta" or "cento" .. numbers[base].cardinal
	make_number(i, cardinal)
end

-- Generate 200 through 900 by 100.
for i = 200, 900, 100 do
	local base = i / 100
	local cardinal = numbers[base].cardinal .. "cento"
	make_number(i, cardinal)
end

-- Include 210 because of the irregular ordinal (duecentodecimo).
make_number(210, "duecentodieci")

make_number(1000, "mille")
make_number(1001, "milleuno")

-- Generate 2000 through 9000 by 1000.
for i = 2000, 9000, 1000 do
	local base = i / 1000
	local cardinal = numbers[base].cardinal .. "mila"
	make_number(i, cardinal)
end

make_number(10000, "diecimila", {"decimillesimo", "diecimillesimo"})
make_number(100000, "centomila")
make_number(1000000, {"[[un]] [[milione]]<link:milione>", "unmilione"}, "milionesimo", "milione")
make_number(2000000, {"[[due]] [[milione|milioni]]", "duemilioni"}, "duemilionesimo")
make_number(power_of(7), {"[[dieci]] [[milione|milioni]]", "diecimilioni"}, {"decimilionesimo", "diecimilionesimo"})
make_number(power_of(8), {"[[cento]] [[milione|milioni]]", "centomilioni"}, "centomilionesimo")
make_number(power_of(9), {"[[un]] [[miliardo]]<link:miliardo>", "unmiliardo"}, "miliardesimo", "miliardo")
make_number(power_of(9, 2), {"[[due]] [[miliardo|miliardi]]", "duemiliardi"}, "duemiliardesimo")
make_number(power_of(10), {"[[dieci]] [[miliardo|miliardi]]", "diecimiliardi"}, {"decimiliardesimo", "diecimiliardesimo"})
make_number(power_of(11), {"[[cento]] [[miliardo|miliardi]]", "centomiliardi"}, "centomiliardesimo")
make_number(power_of(12), {"[[un]] [[bilione]]<link:bilione>", "unbilione"}, "bilionesimo", "bilione")
make_number(power_of(13), {"[[dieci]] [[bilione|bilioni]]", "diecibilioni"}, {"decibilionesimo", "diecibilionesimo"})
make_number(power_of(14), {"[[cento]] [[bilione|bilioni]]", "centobilioni"}, "centobilionesimo")
make_number(power_of(15), {"[[un]] [[biliardo]]<link:biliardo>", "unbiliardo"}, "biliardesimo", "biliardo (numero)")
make_number(power_of(18), {"[[un]] [[trilione]]<link:trilione>", "untrilione"}, "trilionesimo", "trilione")
make_number(power_of(21), {"[[un]] [[triliardo]]<link:triliardo>", "untriliardo"}, "triliardesimo", "triliardo")
make_number(power_of(24), {"[[un]] [[quadrilione]]<link:quadrilione>", "unquadrilione"}, "quadrilionesimo", "quadrilione")
make_number(power_of(27), {"[[un]] [[quadriliardo]]<link:quadriliardo>", "unquadriliardo"}, "quadriliardesimo", "quadriliardo")
make_number(power_of(30), {"[[un]] [[quintilione]]<link:quintilione>", "unquintilione"}, "quintilionesimo", "quintilione")
make_number(power_of(33), {"[[un]] [[quintiliardo]]<link:quintiliardo>", "unquintiliardo"}, "quintiliardesimo") -- no 'quintiliardo' article yet

return export