Module:Case: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
title = "" | title = "" | ||
for _, part in pairs(parts) do | for _, part in pairs(parts) do | ||
title = title .. langObject:ucfirst( | title = title .. langObject:ucfirst(langObject:lc(part)) .. replace | ||
end | end | ||
if table.getn(parts) > 1 then | if table.getn(parts) > 1 then | ||
Line 28: | Line 28: | ||
function p.uppercase_first_letter(frame) | function p.uppercase_first_letter(frame) | ||
return "[[" .. frame.args.link .. "|" .. langObject:ucfirst( | return "[[" .. frame.args.link .. "|" .. langObject:ucfirst(langObject:lc(frame.args.link)) .. "]]" | ||
end | end | ||
function p.lowercase(frame) | function p.lowercase(frame) | ||
return "[[" .. frame.args.link .. "|" .. | return "[[" .. frame.args.link .. "|" .. langObject:lc(frame.args.link) .. "]]" | ||
end | end | ||
return p | return p |
Revision as of 23:29, 22 May 2021
See usage on Script error: The function "title_case" does not exist., Template:u, and template:l.
local p = {} --p stands for package
langObject = mw.getLanguage('simple')
function p.all_words_first_letter_uppercase(frame)
plain = false
if frame.args.plain == "true" then
plain = true
end
split = frame.args.split
if split == "space" then
split = " "
end
replace = split
if frame.args.replace ~= "" then
replace = frame.args.replace
end
parts = mw.text.split(frame.args.link, split, plain)
title = ""
for _, part in pairs(parts) do
title = title .. langObject:ucfirst(langObject:lc(part)) .. replace
end
if table.getn(parts) > 1 then
title = string.sub(title, 0, string.len(title) - string.len(replace))
end
return "[[" .. frame.args.link .. "|" .. title .. "]]"
end
function p.uppercase_first_letter(frame)
return "[[" .. frame.args.link .. "|" .. langObject:ucfirst(langObject:lc(frame.args.link)) .. "]]"
end
function p.lowercase(frame)
return "[[" .. frame.args.link .. "|" .. langObject:lc(frame.args.link) .. "]]"
end
return p