Module:Sandbox/Redlead07/Names Explained

local p = local function dutch(frame) local name = frame.args.name or "" local given_name = string.match(name, "(%w+)") or "" local a = string.match(name, "%w+ (%w+ %w+ %w+)") or string.match(name, "%w+ (%w+ %w+)") or string.match(name, "%w+ (%w+)") or "" local family_name = a return "Given name = "..given_name.." -- Family name = "..family_name.."
"end

local function english(frame) local name = frame.args.name or "" local given_name = string.match(name, "(%w+ %w+)") or "" local family_name = string.match(name, "%w+ (%w+-%w+)") or string.match(name, "%w+ %w+ (%w+)") or "" local suffix = string.match(name, "Jr") or string.match(name, "Sr") or "" local suffix2 = string.match(name, "I") or string.match(name, "II") or string.match(name, "III") or string.match(name, "IV") or string.match(name, "V") or string.match(name, "VI") or string.match(name, "VII") or string.match(name, "VIII") or "" if family_name

string.match(name, "%w+ (%w+-%w+)") then given_name = string.match(name, "(%w+)") end if suffix ~= "" then family_name = string.match(name, "%w+ (%w+)") or "" given_name = string.match(name, "(%w+) %w+") or "" end if suffix2 ~= "" then family_name = string.match(name, "%w+ %w+ (%u%l+)") or "" given_name = string.match(name, "(%w+ %w+) %u%l+") or "" end return "Given name = "..given_name.." -- Family name = "..family_name.."
"end local function french(frame) local name = frame.args.name or "" local given_name = string.match(name, "(%w+-%w+) %w+") or string.match(name, "(%w+) %w+") or "" local family_name = string.match(name, "%w+ (%w+-%w+)") or string.match(name, "%w+ (%w+)") or "" local particles = string.match(name, "%w+ de") or string.match(name, "Du") or string.match(name, "de la") or string.match(name, "Dele") or string.match(name, "Del") or "" if particles ~= "" then family_name = string.match(name, "%w+ (%w+ %w'%w+)") or string.match(name, "%w+ (%w+ %w+%W+%w+)") or string.match(name, "%w+ (%w+ %w+)") or "" family_name = family_name:gsub("^%l", string.upper) end return "Given name = "..given_name.." -- Family name = "..family_name.."
"end

local function spanish(frame) local name = frame.args.name or "" local a = string.match(name, "(%w+%W+%w+) %w+") or "" local b = string.match(name, "(%w+) %w+") or "" local c = string.match(name, "(%W+%w+) %w+") or "" local d = string.match(name, "%w+ (%w+%W+%w+)") or "" local e = string.match(name, "%w+ %w+(%W+%w+)") or "" local f = string.match(name, "%w+(%W+%w+) %w+") or "" local family_name = string.match(name, "%w+ (%w+%W+%w+-%w+%W+%w+)") or string.match(name, "%w+ (%w+%W+%w+ %w+ %w+ %w+)") or string.match(name, "%w+ (%w+%W+%w+ %w+)") or string.match(name, "%w+ (%w+ %w+%W+%w+)") or "" local particles = string.match(name, "del") or "" local particles2 = string.match(name, "de la") or "" local given_name = "" if b ~= "" then given_name = b end if a ~= "" and a ~= d then given_name = a end if c ~= "" and c ~= e and c ~= d and c ~= f then given_name = c end if particles ~= "" then family_name = string.match(name, "%w+ (%w+ %w+ %w+)") or "" family_name = family_name:gsub("^%l", string.upper) given_name = string.match(name, "(%w+) %w+") or "" end if particles2 ~= "" then family_name = string.match(name, "%w+ (%w+ %w+ %w+ %w+)") or "" family_name = family_name:gsub("^%l", string.upper) given_name = string.match(name, "(%w+) %w+") or "" end return "Given name = "..given_name.." -- Family name = "..family_name.."
"end

local function chinese(frame) local name = frame.args.name or "" local a = string.match(name, "%w+ (%w+)") or "" local given_name = string.match(name, "%w+ (%w+-%w+)") or string.match(name, "%w+ %w+ (%w+-%w+)") or string.match(name, "%w+ (%w+)") or "" local family_name = "" local surname = string.match(name, "Lau") or string.match(name, "Lin") or string.match(name, "Zhao") or string.match(name, "Liu") or string.match(name, "Xu") or string.match(name, "Chow") if surname ~= "" then family_name = surname end if surname ~= "" and surname

a then family_name = surname given_name = string.match(name, "(%w+) %w+") end return "Given name = "..given_name.." -- Family name = "..family_name.."
"end function p.test(frame) local name, format = frame.args.name or "", frame.args.format or "" local a = string.match(name, "(%w+) (%w+) (%w+)") or "" local b = string.match(name, "(%W+%w+) (%w+%W+%w+) (%w+)") or string.match(name, "(%w+%W+%w+) (%w+) (%w+%W+%w+)") or string.match(name, "(%w+) (%w+%W+%w+) (%w+)") or "" local surname = string.match(name, "Lau") or string.match(name, "Lin") or string.match(name, "Zhao") or string.match(name, "Liu") or string.match(name, "Xu") or string.match(name, "Chow") or "" local particles = string.match(name, "del") or string.match(name, "de la") or "" local particles2 = string.match(name, "%w+ de") or string.match(name, "Du") or string.match(name, "de la") or string.match(name, "Dele") or string.match(name, "Del") or "" local particle = string.match(name, "%w+ de%w+") or "" local particles3 = string.match(name, "van der") or string.match(name, "van den") or string.match(name, "van") or string.match(name, "La") or "" local suffix = string.match(name, "I") or string.match(name, "II") or string.match(name, "III") or "" local txt = "" if suffix

"" and (particles ~= "" or b ~= "") then format = spanish end if particles2 ~= "" and particle

"" and format

"" then format = french end if particles3 ~= "" then format = dutch end if surname ~= "" then format = chinese end if format

dutch or format

"nl" then txt = dutch(frame) end if format

spanish or format

"es" then txt = spanish(frame) end if format

french or format

"fr" then txt = french(frame) end if format

chinese then txt = chinese(frame) end if format

"" and a ~= "" then txt = english(frame) end if format

"" and surname

"" and a

"" then family_name = string.match(name, "%w+ (%w+-%w+)") or string.match(name, "%w+ (%w+%W+%w+-%w+%W+%w+)") or string.match(name, "%w+-%w+ (%w+)") or string.match(name, "%w+ (%w+)") or "" given_name = string.match(name, "(%w+-%w+) %w+") or string.match(name, "(%w+) %w+%W+%w+") or string.match(name, "(%w+) %w+-%w+") or string.match(name, "(%w+) %w+") or "" txt = "Given name = "..given_name.." -- Family name = "..family_name.."
" end return txtend

return p