Module:languages/names/generate: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


function export.show()
function export.show()
local languages = require("Module:languages").languages
local languages = require("Module:languages/data")
local ret = "return {"
local ret = "return {"
ret = ret .. '\n["num"] = ' .. #languages .. ","
ret = ret .. '\n["num"] = ' .. #languages .. ","
ret = ret .. '["test"] = ' .. languages[1] .. ","
for k, v in ipairs(languages) do
for k, v in ipairs(languages) do
ret = ret .. '\n\t["' .. v.name .. '"] = "' .. v.code .. '",'
ret = ret .. '\n\t["' .. v.name .. '"] = "' .. v.code .. '",'

Revision as of 07:23, 6 August 2023

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

Result

return {
["num"] = 0,
}

local export = {}

function export.show()
	local languages = require("Module:languages/data")
	local ret = "return {"
	ret = ret .. '\n["num"] = ' .. #languages .. ","
	for k, v in ipairs(languages) do
		ret = ret .. '\n\t["' .. v.name .. '"] = "' .. v.code .. '",'
	end
	ret = ret .. "\n}"
	return ret
end

return export