"ഘടകം:Zh" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
Content deleted Content added
+quotes to literals |
turn categories into data table to simplify code + inline remainder of language code; add more comments |
||
വരി 1:
local p = {}
-- articles in which traditional Chinese preceeds simplified Chinese
local t1st = {
["228 Incident"] = true,
Line 13 ⟶ 14:
["Wei Boyang"] = true,
}
-- the labels for each part
local labels = {
["c"] = "Chinese",
Line 28 ⟶ 30:
}
-- article titles for wikilinks for each part
local wlinks = {
["c"] = "Chinese language",
Line 41 ⟶ 44:
}
-- for those parts which are to be treated as languages their ISO code
local ISOlang = {
["c"] = "zh",
["t"] = "zh-Hant",
["s"] = "zh-Hans",
}
-- Categories for different kinds of Chinese text
local cats = {
["s"] = "[[Category:Articles containing simplified Chinese-language text]]",
["t"] = "[[Category:Articles containing traditional Chinese-language text]]",
}
function p.Zh(frame)
local pframe = frame:getParent()
Line 96 ⟶ 105:
local val = args[name]
if (val ~= "") then
if (ISOlang[name]) then -- add language
elseif (name == "p") then -- italicise pinyin
val = "''" .. val .. "''"
Line 108 ⟶ 119:
else
body = body .. "[[" .. wlinks[name] .. "|" .. labels[name] .. "]]: " .. val .. "; "
-- if has associated category add it
if (cats[name]) then
body = body .. cats[name]
end
end
Line 130 ⟶ 145:
end
end
▲ end
▲ params["xml:lang"] = language
▲ local cats = "[[Category:Articles containing " .. displayName .. "-language text]]"
▲ return mw.text.tag({name="span",attr=params, content=contents}) .. cats
return p
|