Module:Case: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


function p.title_case(frame)
function p.title_case(frame)
     return "[[" .. frame.args.link .. "|" .. langObject:uc(frame.args.link) .. "]]"
parts = langObject:split(frame.args.link, " ", true)
title = ""
for part in parts do
  title = title .. langObject:ucfirst(string.lower(part))
end
     return "[[" .. frame.args.link .. "|" .. title .. "]]"
end
end



Revision as of 22:01, 22 May 2021

See usage on Lua error at line 6: attempt to call method 'split' (a nil value)., Template:u, and template:l.


local p = {} --p stands for package

langObject = mw.getLanguage( 'simple' )

function p.title_case(frame)
	parts = langObject:split(frame.args.link, " ", true)
	title = ""
	for part in parts do
	  title = title .. langObject:ucfirst(string.lower(part))
	end
    return "[[" .. frame.args.link .. "|" .. title .. "]]"
end

function p.uppercase_first_letter(frame)
    return "[[" .. frame.args.link .. "|" .. langObject:ucfirst(string.lower(frame.args.link)) .. "]]"
end

function p.lowercase(frame)
    return "[[" .. frame.args.link .. "|" .. string.lower(frame.args.link) .. "]]"
end

return p