Module:auto cat: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 12: Line 12:
if language then break end
if language then break end
end
end
if language == nil then error("Language could not be determined from title") end
return language, label
return language, label
end
end


return export
return export

Revision as of 08:09, 6 August 2023

local export = {}

local function get_language_and_label(title)
	local find_by_name = require("Module:languages").find_by_name
	local language, label
	
	local words = mw.text.split(title, " ")
	for i = 1, #words do
		name = table.concat(words, " ", 1, i)
		label = table.concat(words, " ", i + 1)
		language = find_by_name(name)
		if language then break end
	end
	return language, label
end

return export