Module:Lang-zh and Module:Lang-zh/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
per edit request; adds Tâi-lô romanization support |
No edit summary |
||
Line 109: | Line 109: | ||
local usebrackets = 0 -- whether to have bracketed terms |
local usebrackets = 0 -- whether to have bracketed terms |
||
local numargs = 0 |
local numargs = 0 |
||
local delimiter = ";" |
|||
if args["out"] then |
if args["out"] then |
||
out = args["out"] |
out = args["out"] |
||
usebrackets = 1 |
usebrackets = 1 |
||
end |
|||
if args["delim"] == "none" or args["delim"] == "no" or args["delim"] == "false" then |
|||
delimiter = "" |
|||
elseif args["delim"] then |
|||
delimiter = args["delim"] |
|||
end |
end |
||
Line 238: | Line 245: | ||
-- put individual, potentially comma-separated glosses in single-quotes |
-- put individual, potentially comma-separated glosses in single-quotes |
||
for term in val:gmatch("[^;,]+") do |
for term in val:gmatch("[^;,]+") do |
||
term = string.gsub(term, "^([ \"']*)(.* |
term = string.gsub(term, "^([ \"']*)(.*)([ \"']*)$", "%2") |
||
terms = terms .. "'" .. term .. "', " |
terms = terms .. "'" .. term .. "', " |
||
end |
end |
||
Line 260: | Line 267: | ||
body = body .. label .. val .. " (" |
body = body .. label .. val .. " (" |
||
else |
else |
||
body = body .. label .. val .. " |
body = body .. label .. val .. delimiter .. " " |
||
end |
end |
||
end |
end |
||
Line 266: | Line 273: | ||
if (body > "") then -- check for empty string |
if (body > "") then -- check for empty string |
||
body = string.sub(body, 1, -3) -- chop off final semicolon and space |
if (delimiter > "") then |
||
body = string.sub(body, 1, -3) -- chop off final semicolon and space |
|||
end |
|||
if out and numargs > usebrackets then |
if out and numargs > usebrackets then |
||
-- closing bracket after the rest of the terms |
-- closing bracket after the rest of the terms |
||
Line 272: | Line 281: | ||
end |
end |
||
return body |
return body |
||
else --no named parameters; see if there's a first parameter, ignoring its name |
else -- no named parameters; see if there's a first parameter, ignoring its name |
||
if (args[1]) then |
if (args[1]) then |
||
-- if there is treat it as Chinese |
-- if there is treat it as Chinese |