Module:language tracking

Hello, you have come here looking for the meaning of the word Module:language tracking. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:language tracking, but we will also tell you about its etymology, its characteristics and you will know how to say Module:language tracking in singular and plural. Everything you need to know about the word Module:language tracking you have here. The definition of the word Module:language tracking will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:language tracking, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local function generate_lemmas(langs)
	local output = '<table class="langtrack"><tr class="primary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory(language .. " lemmas", "pages") .. "</th>"
    end

    output = output .. '</tr><tr class="secondary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">]</th>"
    end
	
    output = output .. "</tr></table>"
    
    return output
end

local function generate_nonlemmas(langs)
	local output = '<table class="infobox langtrack"><tr class="primary">'
	
    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory(language .. " non-lemma forms", "pages") .. "</th>"
    end

    output = output .. '</tr><tr class="secondary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">]</th>"
    end

    output = output .. "</tr></table>"
    
    return output
end

local function generate_both(langs)
	local output = '<table class="infobox langtrack"><tr class="primary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory(language .. " lemmas", "pages") .. "</th>"
    end
    
    output = output .. '</tr><tr class="secondary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">]</th>"
    end
    
    output = output .. '</tr><tr class="primary">'
    
    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory(language .. " non-lemma forms", "pages") .. "</th>"
    end

    output = output .. '</tr><tr class="secondary">'

    for _, language in ipairs(langs) do
        output = output .. "<th style=\"padding: 15px\">]</th>"
    end

    output = output .. "</tr></table>"
    
    return output
end

function export.show(frame)
    local args = require("Module:parameters").process(
		frame:getParent().args,
		{
			 = { list = true },
			 = { default = "lemma" },
		})

    local langs = {}

    local languageData = mw.loadData("Module:languages/code to canonical name")

    for _, language in ipairs(args) do
        language = languageData
        table.insert(langs, (language ~= "") and language or nil)
    end
    
    local output

	if args.type == "lemma" then
		output = generate_lemmas(langs) 
	elseif args.type == "nonlemma" then
		output = generate_nonlemmas(langs)
	elseif args.type == "both" then
		output = generate_both(langs)
	else 
		error("Invalid type.")
	end
	
    return output ..  frame:extensionTag("templatestyles", nil, {src = "Template:language tracking/styles.css"})
end

return export