"ഘടകം: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 = {
local cats["c"] = "[[Category:Articles containing " .. displayName .. "Chinese-language text]]",
["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 and category if needed
vallocal params = p.{lang(=ISOlang[name], val)}
params["xml:lang"] = languageISOlang[name]
return val = mw.text.tag({name="span",attr=params, content=contentsval}) .. cats
elseif (name == "p") then -- italicise pinyin
val = "''" .. val .. "''"
Line 108 ⟶ 119:
else
body = body .. "[[" .. wlinks[name] .. "|" .. labels[name] .. "]]: " .. val .. "; "
end
-- if has associated category add it
if (cats[name]) then
body = body .. cats[name]
end
end
Line 130 ⟶ 145:
end
end
 
function p.lang(language, contents)
local displayName = mw.language.fetchLanguageName( language, "en" )
if (displayName ~= "Chinese") then
local langobj = mw.getLanguage("en")
displayName = langobj:lcfirst(displayName)
end
local params = {lang=language}
params["xml:lang"] = language
local cats = "[[Category:Articles containing " .. displayName .. "-language text]]"
return mw.text.tag({name="span",attr=params, content=contents}) .. cats
end
return p
"https://ml.wikipedia.org/wiki/ഘടകം:Zh" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്