Pojdi na vsebino

Modul:Peskovnik/Johnuniq/test

Iz Wikipedije, proste enciklopedije
-- Module:Peskovnik/Johnuniq/test
-- {{#invoke:Peskovnik/Johnuniq/test|main}}
-- Experiment with convertPlural
local function pre_block(text)
	-- Pre tags returned by a module do not act like wikitext <pre>...</pre>.
	return '<pre>\n' ..
		mw.text.nowiki(text) ..
		(text:sub(-1) == '\n' and '' or '\n') ..
		'</pre>\n'
end

local function main(frame)
	local results = {}
	local v
	for _, n in ipairs({ -1.2, 1.0, 1.2 }) do
		v = mw.language.getContentLanguage():convertPlural(n, 'One', 'Two', 'Three', 'Four', 'Five')
		table.insert(results, string.format('%8.1f\t%s\n', n, v))
	end
	for n = -20, 3020 do
		v = mw.language.getContentLanguage():convertPlural(n, 'One', 'Two', 'Three', 'Four', 'Five')
		table.insert(results, string.format('%8d\t%s\n', n, v))
	end
	return pre_block(table.concat(results))
end

return { main = main }