Jump to content

Module:Name in various languages

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by A diehard editor (talk | contribs) at 07:02, 27 November 2023 (IT WORKS). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local lang_mod = require ('Module:Lang');
local get_args = require ('Module:Arguments').getArgs;

local p = {};
local SEPARATOR = '|- style="border-bottom:1px solid #aaa"\n';
local STYLE = "border-bottom:1px solid #aaa";

local function make_table_start(width, font_size, name)
    return '{| class="mw-collapsible mw-collapsed" style="width:'..width..';'..
        'font-size:' .. font_size .. '; text-align:left; border-collapse:collapse;'..'\n'..
        '! colspan=2 style="text-align:center; border-top: 0px;" | '..name..'\n';
end

local function make_language_row(frame, lang_code, lang_text)
    local lang_link_wikilink = lang_mod.name_from_tag({lang_code, ['link'] = 'yes'})
    return "! style=\"padding-left:0.5em\" | "..lang_link_wikilink..
           "\n| "..frame:expandTemplate{title='lang',args={lang_code, lang_text}};
end

function p.main(frame)
	local args = get_args(frame)
    local output  = '';
    output = output .. make_table_start(
    	args.width,
    	args.font_size,
    	args.name) .. SEPARATOR;
    for k,v in pairs(args) do
    	if lang_mod._is_ietf_tag(k) then
        	output = output .. make_language_row(frame,k,v) .. '\n' .. SEPARATOR;
    	end
    end
    output = output .. '|}';
    return output;
end

return p