Content deleted Content added
trying to make checking for validity less taxing |
repair codes with improper capitalization |
||
Line 223:
function p.lang(frame)
local codes = frame.args[1]
-- A three- or two-letter lowercase sequence at beginning of first parameter▼
local languageCode, scriptCode
if codes then
-- One uppercase and three lowercase letters at the end of the first parameter▼
languageCode = find(codes, "%a%a%a?") and (match(codes, "^%s*(%l%l%l?)") or gsub(match(codes, "^%s*(%a%a%a?)"), "(%a%a%a?)", function(a) return lower(a) end, 1) ) or error("No language code was found in the first parameter")
scriptCode = find(codes, "%a%a%a%a%s*$") and (match(codes, "(%u%l%l%l)%s*$") or gsub(match(codes, "(%a%a%a%a)%s*$"), "(%a)(%a%a%a)", function(a, b) return upper(a) .. lower(b) end, 1) ) or nil
else
error("No content in the first parameter")
end▼
local text = frame.args[2] or error("Provide text in the second parameter")
local italics = frame.args["italics"] or frame.args["i"] or "auto"
Line 251 ⟶ 257:
local codes = frame.args[1]
local languageCode, scriptCode
▲ end
if codes then
-- A three- or two-letter lowercase sequence at beginning of first parameter
languageCode =
-- One uppercase and three lowercase letters at the end of the first parameter
scriptCode = find(codes, "%a%a%a%a%s*$") and (match(codes, "(%u%l%l%l)%s*$")
else
error("No content in the first parameter")
|