มอดูล:category tree/poscatboiler/data/วิกิพจนานุกรม
- The following documentation is generated by Template:poscatboiler data submodule documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
This data submodule defines part of Wiktionary's category structure.
For an introduction to the poscatboiler
system and a description of how to add or modify categories, see Module:category tree/poscatboiler/data/documentation.
local raw_categories = {}
local raw_handlers = {}
-----------------------------------------------------------------------------
-- --
-- RAW CATEGORIES --
-- --
-----------------------------------------------------------------------------
raw_categories["วิกิพจนานุกรม"] = {
description = "High level category for material about Wiktionary and its operation.",
parents = {
"มูลฐาน",
},
}
raw_categories["ผู้ใช้วิกิพจนานุกรม"] = {
description = "Pages listing Wiktionarians according to their user rights and categories listing Wiktionarians according to their linguistic and coding abilities.",
breadcrumb = "ผู้ใช้",
additional = "For an automatically generated list of all users, see [[Special:ListUsers]].",
parents = {
{name = "วิกิพจนานุกรม", sort = "ผู้ใช้"},
},
}
-- เปลี่ยนจาก User languages เพื่อไม่ให้ขัดแย้งกับหมวดหมู่ภาษาและกลุ่มภาษา
raw_categories["ทักษะภาษาของผู้ใช้"] = {
description = "Categories listing Wiktionarians according to their linguistic abilities.",
parents = {
"ผู้ใช้วิกิพจนานุกรม",
"Category:Wiktionary multilingual issues",
},
}
-- User languages with invalid code
raw_categories["ทักษะภาษาของผู้ใช้ที่มีรหัสภาษาผิด"] = {
description = "Categories listing Wiktionarians according to their linguistic abilities, where the language code is invalid for Wiktionary.",
additional = "Most of these codes are valid ISO 639-3 codes but are invalid in Wiktionary for various reasons, " ..
"typically due to different choices made regarding splitting and merging languages.",
parents = {
{name = "ทักษะภาษาของผู้ใช้", sort = " "},
},
}
-- เปลี่ยนจาก User scripts เพื่อไม่ให้ขัดแย้งกับหมวดหมู่อักษร
raw_categories["ทักษะอักษรของผู้ใช้"] = {
description = "Categories listing Wiktionarians according to their abilities to read a given script.",
parents = {
"ผู้ใช้วิกิพจนานุกรม",
"Category:Wiktionary multilingual issues",
},
}
raw_categories["User coders"] = {
description = "Categories listing Wiktionarians according to their coding abilities.",
parents = {
"ผู้ใช้วิกิพจนานุกรม",
},
}
raw_categories["ชื่อไม่รองรับ"] = {
description = "Pages with titles that are not supported by the MediaWiki software.",
additional = "For an explanation of the reasons why certain titles are not supported, see [[Appendix:Unsupported titles]].",
parents = {"วิกิพจนานุกรม"},
hidden = true,
}
-----------------------------------------------------------------------------
-- --
-- RAW HANDLERS --
-- --
-----------------------------------------------------------------------------
-- Fancy version of ine() (if-not-empty). Converts empty string to nil, but also strips leading/trailing space.
local function ine(arg)
if not arg then return nil end
arg = mw.text.trim(arg)
if arg == "" then return nil end
return arg
end
local function get_level_params(data)
local speak_verb = "พูด"
if data.typ == "lang" then
local is_sign_language = data.obj and data.obj:getFamilyCode():find("^sgn") or data.name:find("Sign Language$") or data.name:find("^ภาษามือ")
speak_verb = data.args.verb or is_sign_language and "สื่อสาร" or "พูด"
end
return {
["-"] = {
leftcolor = "#99B3FF",
rightcolor = "#E0E8FF",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAME",
script = "ผู้ใช้เหล่านี้อ่านNAME",
coder = "ผู้ใช้เหล่านี้รู้วิธีการเขียนโค้ดNAME",
},
["0"] = {
leftcolor = "#FFB3B3",
rightcolor = "#FFE0E8",
lang = "ผู้ใช้เหล่านี้ไม่เข้าใจNAME (หรือเข้าใจด้วยความยากลำบากเป็นอันมาก)",
script = "ผู้ใช้เหล่านี้'''ไม่สามารถ'''อ่านNAME",
coder = "ผู้ใช้เหล่านี้รู้เกี่ยวกับNAMEเพียง'''เล็กน้อย''' และแค่เลียนแบบการใช้งานที่มีอยู่",
},
["1"] = {
leftcolor = "#C0C8FF",
rightcolor = "#F0F8FF",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEในระดับ'''พื้นฐาน'''",
script = "ผู้ใช้เหล่านี้สามารถอ่านNAMEในระดับ'''พื้นฐาน'''",
coder = "ผู้ใช้เหล่านี้รู้'''พื้นฐาน'''วิธีการเขียนโค้ดNAME และปรับแต่งแก้ไขเล็กน้อย",
},
["2"] = {
leftcolor = "#77E0E8",
rightcolor = "#D0F8FF",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEในระดับ'''กลาง'''",
script = "ผู้ใช้เหล่านี้สามารถอ่านNAMEในระดับ'''กลาง'''",
coder = "ผู้ใช้เหล่านี้รู้คำสั่งNAME'''พอใช้''' และสามารถเข้าใจบางสคริปต์ที่เขียนโดยผู้อื่น",
},
["3"] = {
leftcolor = "#99B3FF",
rightcolor = "#E0E8FF",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEในระดับ'''สูง'''",
script = "ผู้ใช้เหล่านี้สามารถอ่านNAMEในระดับ'''สูง'''",
coder = "ผู้ใช้เหล่านี้สามารถเขียนโค้ดNAMEที่'''ซับซ้อน'''มากขึ้น และสามารถเข้าใจและปรับแต่งสคริปต์ส่วนใหญ่ที่เขียนโดยผู้อื่น",
},
["4"] = {
leftcolor = "#CCCC00",
rightcolor = "#FFFF99",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEในระดับ'''ชำนาญ'''",
script = "ผู้ใช้เหล่านี้สามารถอ่านNAMEในระดับ'''ชำนาญ'''",
coder = "ผู้ใช้เหล่านี้สามารถเขียนและเข้าใจโค้ดNAMEที่'''ซับซ้อนมาก'''",
},
["5"] = {
leftcolor = "#FF5E5E",
rightcolor = "#FF8080",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEในระดับ'''เชี่ยวชาญ'''",
script = "ผู้ใช้เหล่านี้สามารถอ่านNAMEในระดับ'''เชี่ยวชาญ'''",
coder = "ผู้ใช้เหล่านี้สามารถเขียนและเข้าใจโค้ดNAMEในระดับ'''เชี่ยวชาญ'''",
},
["N"] = {
leftcolor = "#6EF7A7",
rightcolor = "#C5FCDC",
lang = "ผู้ใช้เหล่านี้" .. speak_verb .. "NAMEเป็นภาษา'''พื้นถิ่น'''",
script = "ผู้ใช้เหล่านี้ใช้NAMEเป็นอักษร'''พื้นถิ่น'''",
},
}
end
local coder_links = {
Bash = "w:Bash (Unix shell)",
C = "w:C (programming language)",
["C++"] = "w:C++",
["C Sharp"] = {link = "w:C Sharp (programming language)", name = "C#"},
CSS = "w:CSS",
Go = "w:Go (programming language)",
HTML = "w:HTML",
Java = "w:Java (programming language)",
JavaScript = "w:JavaScript",
Julia = "w:Julia (programming language)",
Lisp = "w:Lisp (programming language)",
Lua = "Wiktionary:Scripting",
Perl = "w:Perl",
Python = "w:Python (programming language)",
Ruby = "w:Ruby (programming language)",
Scala = "w:Scala (programming language)",
Scheme = "w:Scheme (programming language)",
template = {link = "Wiktionary:Templates", name = "wiki templates"},
VBScript = "w:VBScript",
}
-- Generic implementation of competency handler for (natural) languages, scripts, and "coders" (= programming languages).
local function competency_handler(data)
local category = data.category
local langtext = data.langtext
local typ = data.typ
local obj = data.obj
local args = data.args
local code = data.code
local name = data.name
local namecat = data.namecat
local level = data.level
local parents = data.parents
local topright = data.topright
local data_addl = data.additional
local parts = {}
local function ins(txt)
table.insert(parts, txt)
end
local level_params = get_level_params(data)
local params = level_params[level or "-"]
if not params then
error(("Internal error: No params for for code '%s', level %s"):format(code, level or "-"))
end
local function insert_text()
if langtext then
ins(langtext)
ins("<hr />")
end
if not params[typ] then
error(("No English text for code '%s', type '%s', level %s"):format(code, typ, level or "-"))
end
ins(params[typ]:gsub("NAME", ("'''" .. namecat .. "'''"):format(name)))
end
local additional
if level then
additional = ("To be included on this list, add {{tl|Babel|%s}} to your user page. Complete instructions are " ..
"available at [[Wiktionary:Babel]]."):format(level == "N" and code or ("%s-%s"):format(code, level)) ..
(data_addl and "\n\n" .. data_addl or "")
else
additional = ("To be included on this list, use {{tl|Babel}} on your user page. Complete instructions are " ..
"available at [[Wiktionary:Babel]].") ..
(data_addl and "\n\n" .. data_addl or "")
end
if level then
ins(('<div style="float:left;border:solid %s 1px;margin:1px">'):format(params.leftcolor))
ins(('<table cellspacing="0" style="width:238px;background:%s"><tr>'):format(params.rightcolor))
ins(('<td style="width:45px;height:45px;background:%s;text-align:center;font-size:14pt">'):format(params.leftcolor))
ins(("'''%s-%s'''</td>"):format(code, level))
ins('<td style="font-size:8pt;padding:4pt;line-height:1.25em">')
insert_text()
ins('</td></tr></table></div><br clear="left">')
return {
description = table.concat(parts),
additional = additional,
breadcrumb = "Level " .. level,
parents = parents,
}, not not args
else
ins(('<div style="float:left;border:solid %s 1px;margin:1px;">\n'):format(params.leftcolor))
ins(('{| cellspacing="0" style="width:260px;background:%s;"\n'):format(params.rightcolor))
ins(('| style="width:45px;height:45px;background:%s;text-align:center;font-size:14pt;" | '):format(params.leftcolor))
ins(("'''%s'''\n"):format(code))
ins('| style="font-size:8pt;padding:4pt;line-height:1.25em;text-align:center;" | ')
insert_text()
ins('\n|}</div><br clear="left">')
return {
topright = topright,
description = table.concat(parts),
additional = additional,
breadcrumb = name,
parents = parents,
}, not not args
end
end
table.insert(raw_handlers, function(data)
local code, level
if not code then
code, level = data.category:match("^User ([a-z][a-z][a-z]?)%-([0-5N])$")
end
if not code then
code, level = data.category:match("^User ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([0-5N])$")
end
if not code then
code = data.category:match("^User ([a-z][a-z][a-z]?)$")
end
if not code then
code = data.category:match("^User ([a-z][a-z][a-z]?%-[a-zA-Z-]+)$")
end
if not code then
return
end
local lang = require("Module:languages").getByCode(code, nil, "allow etym")
if not lang then
-- If unrecognized language and called from inside, we're handling the parents and breadcrumb for a
-- higher-level category, so at least return something.
if not level and data.called_from_inside then
return {
breadcrumb = {name = code, nocap = true}, -- FIXME, scrape langname= category?
parents = {
{name = "ทักษะภาษาของผู้ใช้ที่มีรหัสภาษาผิด", sort = code},
}
}, true
end
if not ine(data.args.langname) then
return
end
end
local params = {
text = {},
verb = {},
langname = {},
commonscat = {},
}
local args = require("Module:parameters").process(data.args, params)
local langname = args.langname or lang:getCanonicalName()
-- Insert text, appropriately script-tagged, unless already script-tagged (we check for '<span'), in which case we
-- insert it directly. Also handle <<...>> in text and convert to bolded link to parent category.
local function wrap(txt)
if not txt then
return
end
-- Substitute <<...>> (where ... is supposed to be the native rendering of the language) with a link to the
-- top-level 'User CODE' category (e.g. [[:Category:User fr]] or [[:Category:User fr-CA]]) if we're in a
-- sublevel category, or to the top-level language category (e.g. [[:Category:French language]] or
-- [[:Category:Canadian English]]) if we're in a top-level 'User CODE' category.
txt = txt:gsub("<<(.-)>>", function(inside)
if level then
return ("'''[[:Category:User %s|%s]]'''"):format(code, inside)
elseif lang then
return ("'''[[:Category:%s|%s]]'''"):format(lang:getCategoryName(), inside)
else
return ("'''%s'''"):format(inside)
end
end)
if txt:find("<span") or not lang then
return txt
else
return require("Module:script utilities").tag_text(txt, lang)
end
end
local function insert_request_cats(parents)
if args.text or code == "en" or code:find("^en%-") then
return
end
local num_pages = mw.site.stats.pagesInCategory(data.category, "pages")
local count_cat, count_sort
if num_pages == 0 then
count_cat = "Requests for translations in user-competency categories with 0 users"
count_sort = "*" .. code
elseif num_pages == 1 then
count_cat = "Requests for translations in user-competency categories with 1 user"
count_sort = "*" .. code
else
local lowernum, uppernum
lowernum = 2
while true do
uppernum = lowernum * 2 - 1
if num_pages <= uppernum then
break
end
lowernum = lowernum * 2
end
count_cat = ("Requests for translations in user-competency categories with %s-%s users"):format(
lowernum, uppernum)
count_sort = "*" .. ("%0" .. #(tostring(uppernum)) .. "d"):format(num_pages)
end
table.insert(parents, {
name = "Requests for translations in user-competency categories by language",
sort = code,
})
table.insert(parents, {
name = count_cat,
sort = count_sort,
})
end
local invalid_lang_warning
if not lang then
invalid_lang_warning = "'''WARNING''': The specified language code is invalid on Wiktionary. Please migrate all " ..
"competency ratings to the closest valid code."
end
local parents
if level then
parents = {
{name = ("User %s"):format(code), sort = level},
}
elseif lang then
parents = {
{name = "ทักษะภาษาของผู้ใช้", sort = code},
{name = lang:getCategoryName(), sort = "user"},
}
if lang:hasType("etymology-only") then
table.insert(parents, {name = lang:getNonEtymological():getCategoryName(), sort = " " .. code})
end
else
parents = {
{name = "ทักษะภาษาของผู้ใช้ที่มีรหัสภาษาผิด", sort = code},
}
end
insert_request_cats(parents)
local topright
if args.commonscat then
local commonscat = require("Module:yesno")(args.commonscat, "+")
if commonscat == "+" or commonscat == true then
commonscat = data.category
end
if commonscat then
topright = ("{{commonscat|%s}}"):format(commonscat)
end
end
local namecat
if level then
namecat = ("[[:Category:User %s|%%s]]"):format(code)
elseif lang then
namecat = ("[[:Category:%s|%%s]]"):format(lang:getCategoryName())
else
namecat = "[[%s]]"
end
local additional
if level then
additional = ("To be included on this list, add {{tl|Babel|%s}} to your user page. Complete instructions are " ..
"available at [[Wiktionary:Babel]]."):format(level == "N" and code or ("%s-%s"):format(code, level)) ..
(invalid_lang_warning and "\n\n" .. invalid_lang_warning or "")
else
additional = ("To be included on this list, use {{tl|Babel}} on your user page. Complete instructions are " ..
"available at [[Wiktionary:Babel]].") ..
(invalid_lang_warning and "\n\n" .. invalid_lang_warning or "")
end
return competency_handler {
category = data.category,
langtext = wrap(args.text),
typ = "lang",
args = args,
obj = lang,
code = code,
name = langname,
namecat = namecat,
level = level,
parents = parents,
topright = topright,
additional = invalid_lang_warning,
}
end)
table.insert(raw_handlers, function(data)
local code, level
if not code then
code, level = data.category:match("^User ([A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
end
if not code then
code = data.category:match("^User ([A-Z][a-z][a-z][a-z][a-z]?)$")
end
if not code then
code, level = data.category:match("^User ([a-z][a-z][a-z]?%-[A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
end
if not code then
code = data.category:match("^User ([a-z][a-z][a-z]?%-[A-Z][a-z][a-z][a-z][a-z]?)$")
end
if not code then
return
end
local sc = require("Module:scripts").getByCode(code)
if not sc then
return
end
local parents
if level then
parents = {
{name = ("User %s"):format(code), sort = level},
}
else
parents = {
{name = "ทักษะอักษรของผู้ใช้", sort = code},
{name = sc:getCategoryName(), sort = "ผู้ใช้"},
}
end
local namecat
local catname = sc:getCanonicalName()
-- Better to display 'Foo script' than just 'Foo', as so many scripts are the same as language names.
if level then
namecat = ("[[:Category:User %s|%s]]"):format(code, sc:getCategoryName())
else
namecat = ("[[:Category:%s|%s]]"):format(sc:getCategoryName(), sc:getCategoryName())
end
return competency_handler {
category = data.category,
typ = "script",
obj = sc,
code = code,
name = sc:getCanonicalName(),
namecat = namecat,
level = level,
parents = parents,
}
end)
table.insert(raw_handlers, function(data)
local code, level
if not code then
code, level = data.category:match("^User ([A-Za-z+-]+) coder%-([0-5N])$")
end
if not code then
code = data.category:match("^User ([A-Za-z+-]+) coder$")
end
if not code or not coder_links[code] then
return
end
local parents
if level then
parents = {
{name = ("User %s coder"):format(code), sort = level},
}
else
parents = {
{name = "User coders", sort = code},
}
end
local langdata = coder_links[code]
if type(langdata) == "string" then
langdata = {link = langdata}
end
local namecat = ("[[%s|%%s]]"):format(langdata.link)
return competency_handler {
category = data.category,
typ = "coder",
code = code,
name = langdata.name or code,
namecat = namecat,
level = level,
parents = parents,
}
end)
return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}