Module:Year category type

විකිපීඩියා වෙතින්

local p = {}

local units = {
	year = "^%d*$",
	year_bc = "^ක්‍රිස්තු පූර්ව %d*$",
	year_ad = "^ක්‍රිස්තු වර්ෂ %d*$",
	decade = "^%d*0 දශකය$",
	decade_bc = "^ක්‍රිස්තු පූර්ව %d*0 දශකය$",
	century = "^%d* වන සියවස$",
	century_bc = "^ක්‍රිස්තු පූර්ව %d* වන සියවස$",
	millennium = "^%d වන සහස්‍රවර්ෂය$",
	millennium_bc = "^ක්‍රිස්තු පූර්ව %d වන සහස්‍රවර්ෂය$",
}

local units_second = {
	year_bc = "^ක්‍රිපූ %d*$",
	century = "^පළමුවන සියවස$",
	century_bc = "^ක්‍රිස්තු පූර්ව පළමුවන සියවස$",
	millennium_bc = "^ක්‍රිස්තු පූර්ව [ ෙපතසඅනද].-වන සහස්‍රවර්ෂය$",
}

local units_third = {
	year_bc = "^ක්‍රි.පූ. %d*$",
}

local units_english = {
	year_bc = "^%d* BC$",
	year_ad = "^AD %d*$",
	decade = "^%d*0s$",
	decade_bc = "^%d*0s BC$",
	century = "^%d*[snrt][tdh].century$",
	century_bc = "^%d*[snrt][tdh].century BC$",
	millennium_bc = "^%d*[snrt][tdh].millennium BC$",
}

function p.main(frame)
	local title = mw.title.getCurrentTitle().text

	for unit, pattern in pairs(units) do
		if string.match(title, pattern) then
			return unit
		end
	end
	-- Additional Functionality (START)
	-- Second round
		for unit, pattern in pairs(units_second) do
		if string.match(title, pattern) then
			return unit
		end
	end
	-- Third round
		for unit, pattern in pairs(units_third) do
		if string.match(title, pattern) then
			return unit
		end
	end
	-- Fallback to English
	for unit, pattern in pairs(units) do
		if string.match(title, pattern) then
			return unit
		end
	end
	-- Additional Functionality (FINISH)
	
	return -1
end

return p
"https://si.wikipedia.org/w/index.php?title=Module:Year_category_type&oldid=542294" වෙතින් සම්ප්‍රවේශනය කෙරිණි