Modul:bosh soʻz/andozalar
Bu modul uchun Modul:bosh soʻz/andozalar/doc nomli hujjat sahifasini yaratishingiz mumkin
local export = {}
local invariable = {
["cmavo"] = true,
["cmene"] = true,
["fu'ivla"] = true,
["gismu"] = true,
["Han tu"] = true,
["hanzi"] = true,
["hanja"] = true,
["jyutping"] = true,
["kanji"] = true,
["lujvo"] = true,
["phrasebook"] = true,
["pinyin"] = true,
["rafsi"] = true,
["romaji"] = true,
}
function export.head_t(frame)
local args = frame:getParent().args
-- Til va yozuv haqida maʼlumot oling
local lang = args[1] or (mw.title.getCurrentTitle().nsText == "Andoza" and "und") or error("Til kodi belgilangan olinmagan. Andozalarini parametr 1 oʻtishi qiling.")
local sc = args["sc"] or ""; if sc == "" then sc = nil end
local cat_sc = args["cat sc"] or ""; if cat_sc == "" then cat_sc = nil end
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
if cat_sc then
cat_sc = (cat_sc and (require("Module:scripts").getByCode(cat_sc) or error("The script code \"" .. cat_sc .. "\" is not valid.")) or nil)
sc = cat_sc
else
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
end
-- Asosiy parametrlarini toʻplang
local sort_key = args["sort"]; if sort_key == "" then sort_key = nil end
local pos = args[2]; if pos == "" then pos = nil end
local cat2 = args["cat2"]; if cat2 == "" then cat2 = nil end
local cat3 = args["cat3"]; if cat3 == "" then cat3 = nil end
-- Modda boshi soʻz va translyatsiyani toʻplang
local heads = {}
local translits = {}
local head = args["head"] or ""
local translit = args["tr"]; if translit == "" then translit = nil end
local i = 1
while head do
if head then
table.insert(heads, head)
translits[#heads] = translit
end
i = i + 1
head = args["bosh" .. i]; if head == "" then head = nil end
translit = args["tr" .. i]; if translit == "" then translit = nil end
end
-- Jinsi va soni texnik xususiyatlarini toʻplang
-- Biri qadar barcha GN parametrlarni (G2, G3 va h.k.) orqali iteratsiyasi boʻshligiga
local genders = {}
local g = args["g"]; if g == "" then g = nil end
local i = 2
while g do
table.insert(genders, g)
g = args["g" .. i]; if g == "" then g = nil end
i = i + 1
end
-- Qurgan shakllarini toʻplang
local inflections = {}
local i = 1
local label = args[i * 2 + 1]
local accel = args["f" .. i .. "accel"]; if accel == "" then accel = nil end
local parts = {label = label, accel = accel}
local m_scripts = nil
while label do
local term = args[i * 2 + 2]; if term == "" then term = nil end
local alt = args["f" .. i .. "alt"]; if alt == "" then alt = nil end
local sc = args["f" .. i .. "sc"]; if sc == "" then sc = nil end
local id = args["f" .. i .. "id"]; if id == "" then id = nil end
local translit = args["f" .. i .. "tr"]; if translit == "" then translit = nil end
local gender = args["f" .. i .. "g"]; if gender == "" then gender = nil end
local qualifier = args["f" .. i .. "qual"]; if qualifier == "" then qualifier = nil end
local nolink = args["f" .. i .. "nolink"]; if nolink == "" then nolink = nil end
local lang = args["f" .. i .. "lang"]; if lang == "" then lang = nil end
if lang ~= nil then
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
end
if term or alt then
if sc then
m_scripts = m_scripts or require("Module:scripts")
sc = (sc and (m_scripts.getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
end
table.insert(parts, {term = term, alt = alt, sc = sc, id = id, translit = translit, genders = {gender}, qualifiers = {qualifier}, nolink = nolink, lang = lang})
end
i = i + 1
label = args[i * 2 + 1]
accel = args["f" .. i .. "accel"]; if accel == "" then accel = nil end
-- Keyingi yorliq boʻlmasa "yoki" keyin o'tgan birini kiritish va yangi yarating.
if label ~= "or" then
-- Oldingi yorliq boʻsh emas, agar faqat joylashtiring.
if (parts.label or "") ~= "" then
table.insert(inflections, parts)
end
parts = {label = label, accel = accel}
end
end
-- Belgilangan/qiling toifalar
local categories = {}
local tracking_categories = {}
if pos then
if not pos:find("s$") and not invariable[pos] then
--require("Module:debug").track("head tracking/singular category")
-- Soʻz qismi koʻplik shakli hosil qiling
if pos:find("x$") then
pos = pos .. "es"
else
pos = pos .. "s"
end
end
table.insert(categories, lang:getCanonicalName() .. " " .. pos .. (cat_sc and " in " .. cat_sc:getCategoryName() or ""))
end
if cat2 then
table.insert(categories, lang:getCanonicalName() .. " " .. cat2)
end
if cat3 then
table.insert(categories, lang:getCanonicalName() .. " " .. cat3)
end
return require("Module:bosh soʻz").full_headword(lang, sc, heads, translits, genders, inflections, categories, sort_key) ..
require("Module:utilities").format_categories(tracking_categories, lang, sort_key)
end
return export