Module:ForeignLanguageTextTable
Appearance
local p = {}
function p.generateTable(frame)
-- Input variables from the template
local lang1 = frame.args["lang1"]
local lang2 = frame.args["lang2"]
local texts = {}
local translations = {}
-- Collect up to 10 text and translation pairs
for i = 1, 10 do
local text = frame.args["text" .. i]
local trans = frame.args["trans" .. i]
if text and trans then
table.insert(texts, text)
table.insert(translations, trans)
end
end
-- Start building the table
local tableStr = '{| class="wikitable"\n'
tableStr = tableStr .. "! " .. lang1 .. " !! " .. lang2 .. "\n"
-- Loop through the texts and translations and add rows to the table
for i = 1, #texts do
tableStr = tableStr .. "|-\n"
tableStr = tableStr .. "| " .. texts[i] .. " || " .. translations[i] .. "\n"
end
-- Close the table
tableStr = tableStr .. "|}"
return tableStr
end
return p