ሞድዩል:Formats
Appearance
Documentation for this module may be created at ሞድዩል:Formats/doc
-- Module to format text strings
local p = {}
function p.url(frame)
local s = frame.args[1]
local change = {}
if string.find(s, '%[') then
local change1 = string.gsub(s,'[%[ | %]]','')
change = string.gsub(change1,'http:%/%/','')
elseif string.find(s, 'http:%/%/') then
change = string.gsub(s,'http:%/%/','')
else
change = s
end
return change
end
function p.formatnum(frame)
local s = frame.args[1]
local language = {}
if s ~= '' or s ~= nil then
if frame.args[2] then
language = frame.args[2]
else
language = 'ti'
end
local num = string.gsub(string.gsub(s,',',''),' ','')
local formatnum = {}
if type(tonumber(num)) == 'number' then
if string.len(num) == 4 or mw.ustring.find(num,'%.') == 5 then
if language == 'ti' then
formatnum = string.gsub(num,'%.',',')
else
formatnum = mw.language.new(language):formatNum(tonumber(num))
end
else
formatnum = mw.language.new(language):formatNum(tonumber(num))
end
return formatnum
else
return s --'<strong class="error">Invalid number</strong> [[መደብ:ዊኪፐድያ:Formatnum errors]]'
end
else
return ''
end
end
return p