Modul:category tree/wiktionary users
Penampilan
- Berikut merupakan pendokumenan yang dijana oleh Templat:category tree data submodule documentation. [sunting]
- Pautan berguna: akar laman • sublaman akar laman • pautan • transklusi • kes ujian • kotak pasir
Submodul data ini mentakrifkan sebahagian daripada struktur kategori Wikikamus.
Untuk pengenalan kepada sistem poscatboiler dan penerangan tentang cara menambah atau mengubah suai kategori, lihat Modul:category tree/data/doc.
local raw_categories = {}
local raw_handlers = {}
local concat = table.concat
local insert = table.insert
local unpack = unpack or table.unpack -- Lua 5.2 compatibility
local string_utilities_module = "Module:string utilities"
-----------------------------------------------------------------------------
-- --
-- RAW CATEGORIES --
-- --
-----------------------------------------------------------------------------
raw_categories["Wiktionary"] = {
description = "Kategori peringkat tinggi untuk bahan tentang Wiktionary dan pengendaliannya.",
parents = "Asas",
}
raw_categories["Statistik Wikikamus"] = {
description = "Categories and pages containing statistics about how Wiktionary is used.",
parents = {"Wiktionary", sort = "Statistik"},
}
raw_categories["Pengguna Wikikamus"] = {
description = "Laman yang menyenaraikan ahli Wikikamus mengikut hak pengguna, serta kategori yang menyenaraikan ahli Wikikamus mengikut keupayaan linguistik dan pengekodan.",
breadcrumb = "Pengguna",
additional = "Untuk senarai semua pengguna yang dijana secara automatik, lihat [[Khas:Senarai pengguna]].",
parents = {"Wiktionary", sort = "Pengguna"},
}
raw_categories["Wikimediawan yang disekat oleh Yayasan Wikimedia"] = {
description = "Pengguna yang telah menerima [[m:Global bans|sekatan sejagat]] yang dikenakan oleh [[m:Wikimedia Foundation|Yayasan Wikimedia]], menurut [[m:WMF Global Ban Policy|Dasar Sekatan Sejagat Yayasan Wikimedia]].",
breadcrumb = "Disekat oleh Yayasan Wikimedia",
parents = "Pengguna Wikikamus",
}
raw_categories["Bahasa pengguna"] = {
description = "Kategori menyenaraikan ahli Wikikamus mengikut keupayaan linguistik mereka.",
parents = {
"Pengguna Wikikamus",
"Kategori:Isu keberbilangan bahasa Wikikamus",
},
}
raw_categories["Bahasa pengguna dengan kod tak sah"] = {
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 = "Bahasa pengguna", sort = " "},
}
raw_categories["Tulisan pengguna"] = {
description = "Kategori menyenaraikan ahli Wikikamus mengikut kebolehan mereka membaca tulisan yang diberikan.",
parents = {
"Pengguna Wikikamus",
"Kategori:Isu keberbilangan bahasa Wikikamus",
},
}
raw_categories["Pengguna pengekod"] = {
description = "Categories listing Wiktionarians according to their coding abilities.",
parents = {"Pengguna Wikikamus"},
}
raw_categories["Keluarga bahasa pengguna"] = {
description = "Kategori ini menyenaraikan ahli Wikikamus mengikut pengetahuan mereka tentang keluarga bahasa tertentu.",
parents = "Pengguna Wikikamus"
}
raw_categories["Laman dengan entri"] = {
description = "Laman yang mengandungi entri bahasa.",
additional = "Subkategori dalam kategori ini digunakan untuk menentukan jumlah bilangan entri pada Wikikamus Bahasa Melayu.",
parents = "Wiktionary",
can_be_empty = true,
hidden = true,
}
raw_categories["Redirects connected to a Wikidata item"] = {
description = "Redirect pages which are connected to a [[d:|Wikidata]] item.",
additional = "These are rarely needed, but are occasionally useful following a page merger, where other wikis may still separate the two.",
parents = "Statistik Wikikamus",
can_be_empty = true,
hidden = true,
}
raw_categories["Tajuk tidak disokong"] = {
description = "Halaman dengan tajuk yang tidak disokong oleh perisian MediaWiki.",
additional = "Untuk penjelasan tentang sebab tajuk tertentu tidak disokong, lihat [[Lampiran:Tajuk tidak disokong]].",
parents = "Wiktionary",
can_be_empty = true,
hidden = true,
}
-- Tracked according to [[phab:T347324]].
for ext, data in pairs {
["DynamicPageList"] = {"DynamicPageList (Wikimedia)", "T287380"},
["EasyTimeline"] = {"EasyTimeline", "T137291"},
["Graph"] = {"Graph", "T334940"},
["JsonConfig"] = {"JsonConfig"},
["Kartographer"] = {"Kartographer"},
["Phonos"] = {"Phonos"},
["Score"] = {"Score"},
["WikiHiero"] = {"WikiHiero", "T344534"},
} do
local link, phab = unpack(data)
raw_categories["Laman menggunakan sambungan " .. ext .. ""] = {
description = ("Laman yang menggunakan sambungan [[mw:Extension:%s|%s]]."):format(link, ext),
additional = phab and ("Lihat [[phab:%s|%s]] pada Phabricator berkenaan maklumat latar belakang mengapa sambungan ini dijejak."):format(phab, phab) or nil,
breadcrumb = ("Menggunakan sambungan %s"):format(ext),
parents = "Statistik Wikikamus",
can_be_empty = true,
hidden = true,
}
end
-----------------------------------------------------------------------------
-- --
-- RAW HANDLERS --
-- --
-----------------------------------------------------------------------------
local function get_level_params(data)
local speak_verb = "cakap"
if data.typ == "lang" then
local is_sign_language = data.obj and data.obj:getFamilyCode() and data.obj:getFamilyCode():find("^sgn") or data.langfam:find("^Bahasa Isyarat")
speak_verb = data.args.verb or is_sign_language and "bertutur dalam" or "cakap"
end
return {
["-"] = {
cssclass = "babel-3",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM!.",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT!.",
coder = "Pengguna tersebut tahu bagaimana menggunakan kod !LANGFAM!.",
family = "Pengguna tersebut faham salah satu daripada bahasa bawah kumpulan !LANGFAM!.",
},
["0"] = {
cssclass = "babel-0",
lang = "Pengguna tersebut tidak tahu berbahasa !LANGFAM! (atau memahaminya dengan kesukaran ketara).",
script = "Pengguna tersebut '''tidak boleh''' baca tulisan !SCRIPT!.",
coder = "Pengguna tersebut tahu '''sedikit''' tentang !LANGFAM! dan hanya tiru penggunaan sedia ada.",
family = "Pengguna tersebut tidak tahu mana-mana bahasa bawah !LANGFAM!.",
},
["1"] = {
cssclass = "babel-1",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM! pada tahap '''asas'''.",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT! pada tahap '''asas'''.",
coder = "Pengguna tersebut tahu '''asas''' bagaimana menulis kod !LANGFAM! kod dan buat pengubahsuaian kecil.",
family = "Pengguna tersebut tahu '''asas''' untuk menyumbang ke !LANGFAM!.",
},
["2"] = {
cssclass = "babel-2",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM! pada tahap '''sederhana'''.",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT! pada tahap '''sederhana'''.",
coder = "Pengguna tersebut menguasai !LANGFAM! pada tahap '''sederhana''', dan boleh memahami beberapa skrip ditulis oleh orang lain.",
family = "Pengguna tersebut '''agak terbiasa''' dengan !LANGFAM!.",
},
["3"] = {
cssclass = "babel-3",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM! pada tahap '''lanjutan''' .",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT! pada tahap '''lanjutan''' .",
coder = "Pengguna tersebut boleh menulis kod !LANGFAM! yang '''lebih kompleks''', dan boleh memahami dan mengubah kebanyakan skrip yang ditulis oleh orang lain.",
family = "Pengguna ini menyumbang secara '''berkala''' untuk !LANGFAM!.",
},
["4"] = {
cssclass = "babel-4",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM! pada tahap '''hampir asli'''.",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT! pada tahap '''hampir asli'''.",
coder = "Pengguna tersebut boleh tulis dan faham akan kod !LANGFAM! yang '''amat kompleks'''.",
},
["5"] = {
cssclass = "babel-5",
lang = "Pengguna tersebut " .. speak_verb .. " bahasa !LANGFAM! pada tahap '''profesional'''.",
script = "Pengguna tersebut boleh baca tulisan !SCRIPT! pada tahap '''profesional'''.",
coder = "Pengguna tersebut boleh tulis dan faham akan kod !LANGFAM! pada tahap'''profesional'''.",
},
["N"] = {
cssclass = "babel-N",
lang = "Pengguna tersebut merupakan penutur '''asli''' bahasa !LANGFAM!.",
script = "Tulisan '''asli''' pengguna tersebut ialah tulisan !SCRIPT!.",
},
}
end
local coder_links = {
Asm = "w:Assembly language",
Bash = "w:Bash (Unix shell)",
C = "w:C (programming language)",
["C++"] = "w:C++",
["C Sharp"] = {link = "w:C Sharp", lang = "C#"},
CSS = "w:Lembaran Gaya Lata",
Go = "w:Go (bahasa pengaturcaraan)",
Haskell = "w:Haskell",
HTML = "w:HTML",
Java = "w:Java (bahasa pengaturcaraan)",
JavaScript = "w:JavaScript",
Julia = "w:Julia (bahasa pengaturcaraan)",
Kotlin = "w:Kotlin (programming language)",
Lisp = "w:LISP",
Lua = "Wikikamus:Pengekodan",
Perl = "w:Perl",
PHP = "w:PHP",
Python = "w:Python",
regex = {link = "w:Regular expression", name = "regular expressions"},
Ruby = "w:Ruby",
Rust = "w:Rust (programming language)",
Scala = "w:Scala (bahasa pengaturcaraan)",
Scheme = "w:Scheme (bahasa pengaturcaraan)",
SQL = "w:SQL",
template = {link = "Wikikamus:Templat", name = "templat wiki"},
TypeScript = "w:TypeScript",
VBScript = "w:VBScript",
}
local custom_script_links = {
IPA = "w:Abjad Fonetik Antarabangsa",
UPA = "w:Uralic Phonetic Alphabet",
}
-- Generic implementation of competency handler for (natural) languages, scripts, families and "coders" (= programming languages).
local function competency_handler(data)
local category = data.category
local langtext = data.langtext
local typ = data.typ
local args = data.args
local code = data.code
local langfam = data.langfam
local langfamcat = data.langfamcat
local script = data.script
local scriptcat = data.scriptcat
local level = data.level
local parents = data.parents
local addl_parents = data.addl_parents
local topright = data.topright
local data_addl = data.additional
local inactive = data.inactive
local parts = {}
local function ins(txt)
insert(parts, txt)
end
local level_params = get_level_params(data)
local params = level_params[level or "-"]
if not params then
error(("Ralat dalaman: Tiada param untuk kod '%s', aras %s"):format(code, level or "-"))
end
local function insert_text()
if langtext then
ins(langtext)
ins("<hr />")
end
if not params[typ] then
error(("Tiada teks bahasa Melayu untuk kod '%s', jenis '%s', aras %s"):format(code, typ, level or "-"))
end
local pattern, repl
if typ == "script" then
pattern = "!SCRIPT!"
repl = ("'''" .. scriptcat .. "'''"):format(script)
else
pattern = "!LANGFAM!"
repl = ("'''" .. langfamcat .. "'''"):format(langfam)
if script then
repl = repl .. (" ditulis dalam '''" .. scriptcat .. "'''"):format(script)
end
end
ins(params[typ]:gsub(pattern, repl))
end
local additional = {}
if level then
insert(additional, ("Untuk disertakan dalam senarai ini, tambah {{tl|Babel|%s}} pada laman pengguna anda. " ..
"Panduan lengkap ada di [[Wikikamus:Babel]]."):format(level == "N" and code or ("%s-%s"):format(code, level)))
else
insert(additional, "Untuk disertakan dalam senarai ini, gunakan {{tl|Babel}} pada laman pengguna anda. " ..
"Panduan lengkap ada di [[Wikikamus:Babel]].")
end
if inactive then
insert(additional, "'''NOTE:''' Users in this category have not been active on the English Wiktionary for at " ..
"least two years and have been moved into the 'inactive' state due to " ..
"[[Wiktionary:Votes/pl-2017-04/Removing inactive editors from user-proficiency categories]].")
parents = {{name = category, sort = " "}}
end
if addl_parents then
for _, addl_parent in ipairs(addl_parents) do
insert(parents, addl_parent)
end
end
if data_addl then
insert(additional, data_addl)
end
local babel_templatestyles = require("Modul:TemplateStyles")("Templat:Babel/style.css")
if level then
ins(('<div class="babel-box %s">'):format(params.cssclass))
ins('<table class="babel-content" style="width:238px"><tr>')
ins('<td class="babel-code" style="font-size:14pt">')
ins(("'''%s-%s'''</td>"):format(code, level))
ins('<td class="babel-text">')
insert_text()
ins('</td></tr></table></div><br clear="left">')
return {
description = concat(parts) .. babel_templatestyles,
additional = concat(additional, "\n\n"),
breadcrumb = inactive and "Inactive" or "Aras " .. level,
parents = parents,
}, not not args
else
ins(('<div class="babel-box %s">\n'):format(params.cssclass))
ins('{| class="babel-content" style="width:260px;"\n')
ins('| class="babel-code" style="font-size:14pt;" | ')
ins(("'''%s'''\n"):format(code))
ins('| class="babel-text" style="text-align:center;" | ')
insert_text()
ins('\n|}</div><br clear="left">')
return {
topright = topright,
description = concat(parts) .. babel_templatestyles,
additional = concat(additional, "\n\n"),
breadcrumb = inactive and "Inactive" or lang,
parents = parents,
}, not not args
end
end
-- Guts of implementation of competency handlers for natural languages (full or etymology-only), possibly with a
-- script attached (e.g. [[Category:User ko-Kore]]).
local function handle_user_lang_maybe_script(data, category, inactive, code, sccode, level, args)
local lang = require("Module:languages").getByCode(code, nil, "allow etym")
local langname = args.langname
local sc, scriptname
if sccode then
sc = require("Module:scripts").getByCode(sccode)
scriptname = args.scriptname
end
local code_with_script = code .. (sccode and "-" .. sccode or "")
if not lang or sccode and not sc 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 {
-- FIXME, scrape langname= category?
breadcrumb = {name = code_with_script, nocap = true},
parents = {name = lang and "Bahasa pengguna dengan kod tulisan tak sah" or
"Bahasa pengguna dengan kod tak sah", sort = code_with_script}
}, true
end
if not langname then
-- Check if the code matches a Wikimedia language (e.g. "ku" for Kurdish). If it does, treat
-- its canonical name as though it had been given as langname=.
local wm_lang = require("Module:wikimedia languages").getByCode(code)
if not wm_lang then
mw.log(("Skipping category '%s' because lang code '%s' is unrecognized and langname= not given"):
format(data.category, code))
return
end
langname = wm_lang:getCanonicalName()
end
if sccode and not sc and not scriptname then
mw.log(("Skipping category '%s' because script code '%s' is unrecognized and scriptname= not given"):
format(data.category, sccode))
return
end
end
if not langname then
if not lang then
error("Internal error: Something went wrong, undefined lang= should have been caught above")
end
langname = lang:getCanonicalName()
end
if not scriptname and sccode then
if not sc then
error("Internal error: Something went wrong, undefined sc= should have been caught above")
end
-- Use `getCategoryName` not `getCanonicalName` to display 'Foo script' than just 'Foo', as so many scripts
-- are the same as language names, and otherwise we get nonsensical output like "These users are native speakers
-- of Korean written in Korean".
scriptname = sc:getCategoryName()
end
-- Insert text, appropriately script-tagged, unless already script-tagged (we check for '<span'), in which case we
-- insert it directly. Also handle <<...>> and <<<...>>> in text and convert to bolded link to parent category.
local function wrap(txt)
if not txt then
return
end
if sccode then
-- Substitute <<<...>>> (where ... is supposed to be the native rendering of the script) with a link to the
-- top-level 'User SCRIPT' category (e.g. [[:Category:User Kore]] if we're in a sublevel category, or to the
-- top-level script category (e.g. [[:Category:Korean script]]) if we're in a top-level 'User CODE-SCRIPT'
-- category.
txt = txt:gsub("<<<(.-)>>>", function(inside)
if level then
return ("'''[[:Kategori:Pengguna %s|%s]]'''"):format(sccode, inside)
elseif sc then
return ("'''[[:Kategori:%s|%s]]'''"):format(sc:getCategoryName(), inside)
else
return ("'''%s'''"):format(inside)
end
end)
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 ("'''[[:Kategori:Pengguna %s|%s]]'''"):format(code, inside)
elseif lang then
return ("'''[[:Kategori:%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("Modul:script utilities").tag_text(txt, lang, sc)
end
end
local function get_request_cats()
if args.text or code == "ms" or code:find("^ms%-") or inactive 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 = "Permintaan terjemahan dalam kategori kecekapan pengguna seramai 0 pengguna"
count_sort = "*" .. code_with_script
elseif num_pages == 1 then
count_cat = "Permintaan terjemahan dalam kategori kecekapan pengguna seramai 1 pengguna"
count_sort = "*" .. code_with_script
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 = ("Permintaan terjemahan dalam kategori kecekapan pengguna seramai %s-%s pengguna"):format(
lowernum, uppernum)
count_sort = "*" .. ("%0" .. #(tostring(uppernum)) .. "d"):format(num_pages)
end
local addl_parents = {}
insert(addl_parents, {
name = "Permintaan terjemahan dalam kategori kecekapan pengguna mengikut bahasa",
sort = code_with_script,
})
insert(addl_parents, {
name = count_cat,
sort = count_sort,
})
return addl_parents
end
local invalid_lang_warning
if not lang then
invalid_lang_warning = "'''AMARAN''': Kod bahasa yang dinyatakan tidak sah di Wikikamus. Tolong pindahkan semua " ..
"penilaian kecekapan kepada kod sah terdekat."
end
local parents
if level then
parents = {("Pengguna %s"):format(code_with_script), sort = level}
elseif sccode then
parents = {}
insert(parents, {name = ("Pengguna %s"):format(code), sort = sccode})
insert(parents, {name = ("Pengguna %s"):format(sccode), sort = code})
elseif lang then
parents = {}
if lang:hasType("etymology-only") then
local full_code = lang:getFullCode()
local sort_key = code:gsub(("^%s%%-"):format(require(string_utilities_module).pattern_escape(full_code)),
"")
insert(parents, {name = ("Pengguna %s"):format(full_code), sort = sort_key})
else
insert(parents, {name = "Bahasa pengguna", sort = code})
end
insert(parents, {name = lang:getCategoryName(), sort = "pengguna"})
else
parents = {"Bahasa pengguna dengan kod tak sah", sort = code}
end
local addl_parents = get_request_cats()
local topright
if args.commonscat then
local commonscat = require("Modul:yesno")(args.commonscat, "+")
if commonscat == "+" or commonscat == true then
commonscat = data.category
end
if commonscat then
topright = ("{{commonscat|%s}}"):format(commonscat)
end
end
local langcat
if level then
langcat = ("[[:Kategori:Pengguna %s|%%s]]"):format(code)
elseif lang then
langcat = ("[[:Kategori:%s|%%s]]"):format(lang:getCategoryName())
else
langcat = "[[%s]]"
end
local scriptcat
if sccode then
if level then
scriptcat = ("[[:Kategori:Pengguna %s|%%s]]"):format(sccode)
elseif sc then
scriptcat = ("[[:Kategori:%s|%%s]]"):format(sc:getCategoryName())
else
scriptcat = "[[%s]]"
end
end
return competency_handler {
category = category,
inactive = inactive,
langtext = wrap(args.text),
typ = "lang",
args = args,
obj = lang,
code = code_with_script,
langfam = langname,
langfamcat = langcat,
script = scriptname,
scriptcat = scriptcat,
level = level,
parents = parents,
addl_parents = addl_parents,
topright = topright,
additional = invalid_lang_warning,
}
end
-- Hander for categories named [[Category:User LANG-SCRIPT]] or [[Category:User LANG-SCRIPT-#]] where # is a
-- competency level (0 through 5 or N), e.g. [[Category:zh-Hans]] or [[Category:yue-Hant-N]]. It's a bit tricky because
-- of the multitude of language formats, e.g. ko-KP is a language code (etym variety) but ko-Kore is a combination
-- lang + script code. We depend on the fact that all script codes are currently of the form Xxxx or Xxxxx, and check
-- for that first. We also need to run prior to the lang-only handler (next handler) so it doesn't try to interpret
-- the script code as an etym variant code.
--
-- Note that there are current categories named things like 'zh-Hant-TW' and 'zh-Hant-HK-3', which we don't support.
-- They should be renamed to some supported code, e.g. 'cmn-TW-Hant' and 'yue-HK-Hant-3'.
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, sccode, level = category:match("^Pengguna ([a-z][a-z][a-z]?)%-([A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
if not code then
code, sccode, level =
category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
end
if not code then
code, sccode = category:match("^Pengguna ([a-z][a-z][a-z]?)%-([A-Z][a-z][a-z][a-z][a-z]?)$")
end
if not code then
code, sccode = category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([A-Z][a-z][a-z][a-z][a-z]?)$")
end
if not code then
return
end
local args = require("Module:parameters").process(data.args, {
text = true,
verb = true,
langname = true,
scriptname = true,
scname = {alias_of = "scriptname"},
commonscat = true,
})
return handle_user_lang_maybe_script(data, category, inactive, code, sccode, level, args)
end)
-- Hander for categories named [[Category:User LANG]] e.g. [[Category:User en]], [[Category:User en-US]],
-- [[Category:User ine-pro]] or [[Category:User LANG-#]] where # is a competency level (0 through 5 or N) e.g.
-- [[Category:User en-N]] or [[Category:User ndl-nl-1]].
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, level = category:match("^Pengguna ([a-z][a-z][a-z]?)%-([0-5N])$")
if not code then
code, level = category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([0-5N])$")
end
if not code then
code = category:match("^Pengguna ([a-z][a-z][a-z]?)$")
end
if not code then
code = category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)$")
end
if not code then
return
end
local args = require("Module:parameters").process(data.args, {
text = true,
verb = true,
langname = true,
commonscat = true,
})
return handle_user_lang_maybe_script(data, category, inactive, code, nil, level, args)
end)
-- Handler for scripts.
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, level = category:match("^Pengguna ([A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
if not code then
code = category:match("^Pengguna ([A-Z][a-z][a-z][a-z][a-z]?)$")
end
if not code then
code, level = category:match("^Pengguna ([a-z][a-z][a-z]?%-[A-Z][a-z][a-z][a-z][a-z]?)%-([0-5N])$")
end
if not code then
code = category:match("^Pengguna ([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 = {("Pengguna %s"):format(code), sort = level}
else
parents = {
{name = "Tulisan pengguna", sort = code},
{name = sc:getCategoryName(), sort = "pengguna"},
}
end
local scriptcat
-- Better to display 'Foo script' than just 'Foo', as so many scripts are the same as language names.
if level then
scriptcat = ("[[:Kategori:Pengguna %s|%s]]"):format(code, sc:getCategoryName())
else
scriptcat = ("[[:Kategori:%s|%s]]"):format(sc:getCategoryName(), sc:getCategoryName())
end
return competency_handler {
category = category,
inactive = inactive,
typ = "script",
obj = sc,
code = code,
script = sc:getCanonicalName(),
scriptcat = scriptcat,
level = level,
parents = parents,
}
end)
-- Handler for "custom" scripts (e.g. IPA).
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, level
if not code then
code, level = category:match("^Pengguna ([A-Za-z-]+)%-([0-5N])$")
end
if not code then
code = category:match("^Pengguna ([A-Za-z-]+)$")
end
if not code or not custom_script_links[code] then
return
end
local parents
if level then
parents = {("Pengguna %s"):format(code), sort = level}
else
parents = {"Tulisan pengguna", sort = code}
end
local scriptdata = custom_script_links[code]
if type(scriptdata) == "string" then
scriptdata = {link = scriptdata}
end
local scriptcat = ("[[%s|%%s]]"):format(scriptdata.link)
return competency_handler {
category = category,
inactive = inactive,
typ = "script",
code = code,
script = scriptdata.script or code,
scriptcat = scriptcat,
level = level,
parents = parents,
}
end)
-- Handler for programming languages.
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, level
if not code then
code, level = category:match("^Pengguna pengekod ([A-Za-z+-]+) ([0-5N])$")
end
if not code then
code = category:match("^Pengguna pengekod ([A-Za-z+-]+) $")
end
if not code or not coder_links[code] then
return
end
local parents
if level then
parents = {("Pengguna pengekod %s"):format(code), sort = level}
else
parents = {"Pengguna pengekod", sort = code}
end
local langdata = coder_links[code]
if type(langdata) == "string" then
langdata = {link = langdata}
end
local langcat = ("[[%s|%%s]]"):format(langdata.link)
return competency_handler {
category = category,
inactive = inactive,
typ = "coder",
code = code,
langfam = langdata.lang or code,
langfamcat = langcat,
level = level,
parents = parents,
}
end)
-- Handler for language families.
insert(raw_handlers, function(data)
local category, inactive = data.category:match("^(.*) (%(tak aktif%))$")
category = category or data.category
local code, level = category:match("^Pengguna ([a-z][a-z][a-z]?)%-([0-5N])$")
if not code then
code, level = category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([0-5N])$")
end
if not code then
code = category:match("^Pengguna ([a-z][a-z][a-z]?)$")
end
if not code then
code = category:match("^Pengguna ([a-z][a-z][a-z]?%-[a-zA-Z-]+)$")
end
if not code then
return
end
local fam = require("Modul:families").getByCode(code)
if not fam then
return
end
local parents
if level then
parents = {("Pengguna %s"):format(code), sort = level}
else
parents = {
{name = "Keluarga bahasa pengguna", sort = code},
{name = fam:getCategoryName(), sort = "pengguna"},
}
end
local famcat
if level then
famcat = ("[[:Kategori:Pengguna %s|%s]]"):format(code, fam:getCategoryName())
else
famcat = ("[[:Kategori:%s|%s]]"):format(fam:getCategoryName(), fam:getCategoryName())
end
return competency_handler {
category = category,
inactive = inactive,
typ = "family",
obj = fam,
code = code,
langfam = fam:getCanonicalName(),
langfamcat = famcat,
level = level,
parents = parents,
}
end)
insert(raw_handlers, function(data)
local n, suffix = data.category:match("^Laman dengan (%d+) entr(.+)$")
-- Only match if there are no leading zeroes and the suffix is correct.
if not (n and not n:match("^0%d") and suffix == (n == "1" and "i" or "i")) then
return
end
return {
breadcrumb = ("%d entr%s"):format(n, suffix),
description = ("Laman yang mengandungi %s entr%s bahasa."):format(n, suffix),
additional = "Kategori ini sebagaimana semua kategori lain digunakan untuk menentu jumlah bilangan entri pada Wikikamus Bahasa Melayu",
hidden = true,
can_be_empty = true,
parents = {
{name = "Laman dengan entri", sort = require("Module:category tree").numeral_sortkey(n)},
n == "0" and "Penyelenggaraan Wikikamus" or nil, -- "Pages with 0 entries" only contains pages with something wrong.
},
}
end)
return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}