Module:languages/names/generate

From Laenkea
< Module:languages‎ | names
Revision as of 07:11, 6 August 2023 by Maria (talk | contribs) (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")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 6: bad argument #1 to 'ipairs' (table expected, got nil).</span></strong>

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