Content deleted Content added
Replace Module:No globals with require( "strict" ) |
Copy from sandbox per request on talk |
||
Line 79:
["sl"] = true,
}
-- Categories for different kinds of Chinese text
local cats = {
Line 95 ⟶ 96:
function p._Zh(args)
local uselinks =
local uselabels =
local capfirst = args["scase"] ~= nil
local out = nil -- which term to put before the brackets
local usebrackets = nil -- whether to have bracketed terms
if args["out"] then
out = args["out"]
usebrackets = true
end
local t1 = false -- whether traditional Chinese characters go first
local j1 = false -- whether Cantonese Romanisations go first
Line 131 ⟶ 138:
orderlist[9] = "w"
end
if out then
for i, v in ipairs (orderlist) do
if v == out then
table.remove(orderlist, i)
table.insert(orderlist, 1, v)
break
end
end
end
-- rename rules. Rules to change parameters and labels based on other parameters
if args["hp"] then
Line 147 ⟶ 162:
args["s"] = nil
args["t"] = nil
if out == "s" or out == "t" then
out = "c"
end
elseif (not (args["s"] and args["t"])) then
-- use short label if only one of simplified and traditional
Line 189 ⟶ 207:
params = {["lang"] = ISOlang[part]}
val = mw.text.tag({name="span",attrs=params, content=val})
elseif
-- put individual, potentially comma-separated glosses in single-quotes
val = "'" .. val .. "'"▼
for term in val:gmatch("[^;,]+") do
term = string.gsub(term, "^([ \"']*)(.*)([ \"']*)$", "%2")
mw.log(term)
terms = terms .. "'" .. term .. "', "
end
val = string.sub(terms, 1, -3)
elseif (part == "tr") then
-- put translations in double quotes
end
if (italic[part]) then
Line 203 ⟶ 230:
end
-- add both to body
if i == 1 and usebrackets then
body = body .. label .. val .. "; "▼
-- opening bracket after the `out` term
body = label .. val .. " ("
else
▲ body = body .. label .. val .. "; "
end
end
end
if (body > "") then -- check for empty string
if usebrackets then
-- closing bracket after the rest of the terms
body = body .. ")"
end
return body
else --no named parameters; see if there's a first parameter, ignoring its name
if (args[1]) then
|