Module:languages/names/generate: Difference between revisions

From Laenkea
Jump to navigation Jump to search
(Created page with "local export = {} function export.show() local languages = require("Module:languages").languages local ret = "return {" for k, v in ipairs(languages) do ret = ret + '\n\t["' .. v.name .. '"] = "' .. v.code .. '",' end ret = ret .. "\n}" return ret end return export")
 
No edit summary
Tag: Reverted
Line 1: Line 1:
local export = {}
local export = {}


function export.show()
function export.show(frame)
local wrap_b = (frame.args["wrap"] and ("<" .. frame.args["wrap"] .. ">")) or ""
local wrap_e = (frame.args["wrap"] and ("</" .. frame.args["wrap"] .. ">")) or ""
local languages = require("Module:languages").languages
local languages = require("Module:languages").languages
local ret = "return {"
local ret = "return {"
Line 8: Line 10:
end
end
ret = ret .. "\n}"
ret = ret .. "\n}"
return ret
return wrap_b .. ret .. wrap_e
end
end


return export
return export

Revision as of 07:14, 6 August 2023

Generates up-to-date output that can be used to set the value of Module:languages/names.

Result

<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-0">Lua error at line 8: bad argument #1 to 'ipairs' (table expected, got nil).</span></strong>

local export = {}

function export.show(frame)
	local wrap_b = (frame.args["wrap"] and ("<" .. frame.args["wrap"] .. ">")) or ""
	local wrap_e = (frame.args["wrap"] and ("</" .. frame.args["wrap"] .. ">")) or ""
	local languages = require("Module:languages").languages
	local ret = "return {"
	for k, v in ipairs(languages) do
		ret = ret + '\n\t["' .. v.name .. '"] = "' .. v.code .. '",'
	end
	ret = ret .. "\n}"
	return wrap_b .. ret .. wrap_e
end

return export