Module:Lang-zh: Difference between revisions

Content deleted Content added
Make regex less greedy so that it removes trailing markup
Publishing User:Northern Moonlight's implementation of new fields to specify locale-specific character glyphs according to the IETF standard
 
(2 intermediate revisions by the same user not shown)
Line 28:
["sl"] = "Sidney Lau",
["poj"] = "Pe̍h-ōe-jī",
["tl"] = "Tâi-lô",
["zhu"] = "Zhuyin Fuhao",
["l"] = "lit.",
Line 45 ⟶ 46:
["sl"] = "Sidney Lau romanisation",
["poj"] = "Pe̍h-ōe-jī",
["tl"] = "Tâi-uân Lô-má-jī Phing-im Hong-àn",
["zhu"] = "Bopomofo",
["l"] = "Literal translation",
Line 62 ⟶ 64:
["sl"] = "yue-Latn",
["poj"] = "nan-Latn",
["tl"] = "nan-Latn-tailo",
["zhu"] = "zh-Bopo",
}
Line 73 ⟶ 76:
["sl"] = true,
["poj"] = true,
["tl"] = true,
}
 
Line 105 ⟶ 109:
local usebrackets = 0 -- whether to have bracketed terms
local numargs = 0
local regionalvariant = nil
if args["out"] then
Line 134 ⟶ 139:
 
-- based on setting/preference specify order
local orderlist = {"c", "s", "t", "p", "tp", "w", "j", "cy", "sl", "poj", "tl", "zhu", "l", "tr"}
if (t1) then
orderlist[2] = "t"
Line 149 ⟶ 154:
if (poj1) then
orderlist[4] = "poj"
orderlist[5] = "ptl"
orderlist[6] = "tpp"
orderlist[7] = "wtp"
orderlist[8] = "jw"
orderlist[9] = "cyj"
orderlist[10] = "slcy"
orderlist[11] = "sl"
end
 
Line 165 ⟶ 171:
-- if also Tongyu pinyin use full name for Hanyu pinyin
labels["p"] = "Hanyu Pinyin"
end
-- specify traditional Chinese variants
if args["t_hk"] then
args["t"] = args["t_hk"]
regionalvariant = "HK"
elseif args["t_tw"] then
args["t"] = args["t_tw"]
regionalvariant = "TW"
end
Line 227 ⟶ 242:
if (ISOlang[part]) then
-- add span for language if needed
params = {["lang"] = ISOlang[part] .. (regionalvariant and "-" .. regionalvariant or "")}
val = mw.text.tag({name="span",attrs=params, content=val})
elseif (part == "l") then
local terms = ""
-- put individual, potentially comma-separated glosses in single- quotes
-- (first strip leading and trailing whitespace and quotes, including bold/italic markup)
for term in val:gmatch("[^;,]+") do
term = stringmw.gsubtext.trim(term, "^([ %s\"']*)(.*?)([ \"']*)$", "%2")
terms = terms .. "'" .. term .. "', "
end
Line 239 ⟶ 255:
elseif (part == "tr") then
-- put translations in double quotes
-- (first strip leading and trailing spaces and quotes, including bold/italic markup)
val = mw.text.trim(val, "%s\"'")
val = """ .. val .. """
end