require('strict')
local p =
-- articles in which traditional Chinese preceeds simplified Chineselocal t1st =
-- the labels for each part local labels =
-- article titles for wikilinks for each partlocal wlinks =
-- for those parts which are to be treated as languages their ISO codelocal ISOlang =
local italic =
local superscript = -- Categories for different kinds of Chinese textlocal cats =
function p.Zh(frame) -- load arguments module to simplify handling of args local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) return p._Zh(args)end function p._Zh(args) local uselinks = not (args["links"]
"no") -- whether to have labels local capfirst = args["scase"] ~= nil local t1 = false -- whether traditional Chinese characters go first local j1 = false -- whether Cantonese Romanisations go first local testChar if (args["first"]) then for testChar in mw.ustring.gmatch(args["first"], "%a+") do if (testChar
"j") then j1 = true end end end if (t1
true end
-- based on setting/preference specify order local orderlist = if (t1) then orderlist[2] = "t" orderlist[3] = "s" end if (j1) then orderlist[4] = "j" orderlist[5] = "cy" orderlist[6] = "sl" orderlist[7] = "p" orderlist[8] = "tp" orderlist[9] = "w" end -- rename rules. Rules to change parameters and labels based on other parameters if args["hp"] then -- hp an alias for p ([hanyu] pinyin) args["p"] = args["hp"] end if args["tp"] then -- if also Tongyu pinyin use full name for Hanyu pinyin labels["p"] = "Hanyu Pinyin" end if (args["s"] and args["s"]
local body = "" -- the output string local params -- for creating HTML spans local label -- the label, i.e. the bit preceeding the supplied text local val -- the supplied text -- go through all possible fields in loop, adding them to the output for i, part in ipairs(orderlist) do if (args[part]) then -- build label label = "" if (uselabels) then label = labels[part] if (capfirst) then label = mw.language.getContentLanguage:ucfirst(label) capfirst = false end if (uselinks) then label = "" .. label .. "" end if (labels[part] ~= "lit.") then label = label .. ":" else label = "" .. label .. "" end label = label .. " " end -- build value val = args[part] if (cats[part]) and mw.title.getCurrentTitle.namespace
"l") or (part
0 then -- if current page in article namespace val = cats["c"] .. args[1] else val = args[1] end params = val = mw.text.tag return label .. val end return "" endend
return p