Module:Formatnum

Iz Medžuviki, svobodnoj enciklopedije
Jump to navigation Jump to search

Nema teksta dokumentacije.

--
-- Module for Interslavic number formatting
-- This module can be replaced by {{formatnum:}} declaration when Interslavic MediaWiki localisation will be created.
-- Source: https://sites.google.com/site/neoslavonictutorial/lessons/9
--
local p = {}

-- For usage in other modules
function p._formatnum(num)
	num = tonumber(num)
	if num == nil then
		return num
	end
	local lang = mw.getContentLanguage()
	num = lang:formatNum(num):gsub('%,', ' '):gsub('%.', ',')
	
	return num
end

-- For usage in templates
function p.formatnum(frame)
	local args = frame.args
	local num = args[1]
	if num == nil or num == '' then
		return
	end
	
	return p._formatnum(num)
end

return p