require ('strict');
local default_caption = 'যোগকৃত শব্দ';local words_header = 'ভুক্তির শিরোনাম';local counts_header = 'শব্দসংখ্যা';local total_header = 'মোট শব্দসংখ্যা';
local lang_obj = mw.language.getContentLanguage;
--
local function main (frame) local args_t = require ('Module:Arguments').getArgs (frame);
local word_table = mw.html.create ("table") -- create a wikitable of competition words :addClass ('wikitable sortable')
word_table:node (mw.html.create ('caption'):wikitext (args_t.caption or default_caption)); -- add a table caption for accessability
word_table:node (mw.html.create ("tr") -- create a header row :node (mw.html.create ("th"):attr ('style', 'width: 10em;'):wikitext (words_header)) :node (mw.html.create ("th"):attr ('style', 'width: 10em;'):wikitext (counts_header)) ); local word = nil; local count = nil; local total_count = 0;
for i, identifier in ipairs (args_t) do -- spin through the template-supplied parameters in order if 0 ~= i % 2 then word = args_t[i]; -- odd numbered parameters are words else count = lang_obj:parseFormattedNumber (args_t[i]); -- even numbered parameters are counts; unformat and convert to number end
if word and count then word_table:node (mw.html.create ("tr") -- create a new table row :node (mw.html.create ("td"):wikitext ('' .. word .. '')) -- add wikilinked 'word' :node (mw.html.create ("td"):wikitext (lang_obj:formatNum (count))) -- add fomatted 'count' ); total_count = total_count + count; word = nil; -- unset for the next word/count pair count = nil; end end
word_table:node (mw.html.create ("tr"):attr ('class', 'sortbottom') -- create the bottom-sorted totals row :node (mw.html.create ("th"):attr ('scope', 'row'):wikitext (total_header)) :node (mw.html.create ("td"):wikitext (lang_obj:formatNum (tonumber(total_count)))) );
return word_table:allDone; -- and doneend
----------------------------< E X P O R T S >----------------------------------------------------------------
return