Modül:ms-başlıkbaşı

Vikisözlük sitesinden
Modül belgelemesi [Düzenle] [Tazele]

Bu Lua modülü, şu şablonların çıktısını vermektedir:


local export = {}
local pos_functions = {}

local u = mw.ustring.char
local lang = require("Modül:diller").getirKodaGore("ms")
local PAGENAME = mw.title.getCurrentTitle().text
local script = require("Modül:alfabeler").bulEnIyiAlfabe(PAGENAME, lang) -- Latn or ms-Arab

function export.show(frame)

    local args = frame:getParent().args
    local poscat = frame.args[1] or error(
                       "Part of speech has not been specified. Please pass parameter 1 to the module invocation.")

    local head = args["baş"] or ""
    if (mw.ustring.find(PAGENAME, "اء[وي]")) then
        head = mw.ustring
                   .gsub(PAGENAME, "(ا)(ء)([وي])", "%1<sup>%2</sup>%3") -- superscript hamza
    end

    local data = {
        dil = lang,
        alf = script,
        soz_kategorisi = poscat,
        kategoriler = {},
        baslar = {head},
        alfabecevler = {"-"},
        cekimler = {}
    }

    if (mw.ustring.find(head, "[كڬ]")) or
        (args["j"] and mw.ustring.find(args["j"], "[كڬ]")) or
        (args["j2"] and mw.ustring.find(args["j2"], "[كڬ]")) or
        (args["j3"] and mw.ustring.find(args["j3"], "[كڬ]")) then
        table.insert(data.kategoriler, "Malay terms with incorrect Jawi spelling")
        error("Please use ک in place of ك and ݢ in place of ڬ.")
    end

    local special_marks = "[" .. u(0x200B) .. "-" .. u(0x200F) .. "]" -- ZWSP, ZWNJ, ZWJ, LRM, RLM
    if (mw.ustring.find(head, special_marks)) or
        (args["j"] and mw.ustring.find(args["j"], special_marks)) or
        (args["j2"] and mw.ustring.find(args["j2"], special_marks)) or
        (args["j3"] and mw.ustring.find(args["j3"], special_marks)) then
        table.insert(data.kategoriler, "Malay terms with incorrect Jawi spelling")
        error("Please remove ZWSP, ZWNJ, ZWJ, LRM, and RLM from title/headword.")
    end

    function export.affixation(text, affix)
        if affix == "-" then
            text = text .. "-" .. text
        elseif mw.ustring.match(affix, "^%-.+%-$") then
            first_consonant = mw.ustring.match(text, "^[^aeiou]+")
            text = first_consonant .. mw.ustring.sub(affix, 2, -2) ..
                       mw.ustring.sub(text, mw.ustring.len(first_consonant) + 1,
                                      -1)
        else
            text = gsub(affix, "%-", "#" .. text)
            text = gsub(text, "N([^aeiou]*)([aeiou])([^aeiou]*)$", "nge%1%2%3")
            text = gsub(text, "meN#p", "memp")
            for pattern, replacement in pairs(pattern_replacements) do
                text = gsub(text, pattern, replacement)
            end
            text = gsub(text, "[MNR]#?", letter_replacements)
            text = gsub(text, "#", "")
        end
        return text
    end

    local letter_replacements = {["M"] = "m", ["N#"] = "ng", ["R#"] = "r"}

    local jawi = {etiket = "Jawi spelling"}
    local sc_Arab = require("Modül:alfabeler").getirKodaGore("Arab")
    if args["j"] then table.insert(jawi, {term = args["j"], sc = sc_Arab}) end
    if args["j2"] then table.insert(jawi, {term = args["j2"], sc = sc_Arab}) end
    if args["j3"] then table.insert(jawi, {term = args["j3"], sc = sc_Arab}) end
    if #jawi > 0 then table.insert(data.cekimler, jawi) end

    local rumi = {etiket = "Rumi spelling"}
    local sc_Latn = require("Modül:alfabeler").getirKodaGore("Latn")
    if args["r"] then table.insert(rumi, {term = args["r"], sc = sc_Latn}) end
    if args["r2"] then table.insert(rumi, {term = args["r2"], sc = sc_Latn}) end
    if args["r3"] then table.insert(rumi, {term = args["r3"], sc = sc_Latn}) end
    if #rumi > 0 then table.insert(data.cekimler, rumi) end

    if script:getirKod() == "Arab" then
        table.insert(data.kategoriler, "Malay terms with Jawi spelling")
    end

    if pos_functions[poscat] then pos_functions[poscat](args, data) end

    return require("Modül:başlık başı").tam_baslikbasi(data)

end

pos_functions["adlar"] = function(args, data)

    local pl = {etiket = "çoğulu"}
    if args["pl"] == "-" then
        table.insert(data.kategoriler, "Malay uncountable nouns")
    else
        if args["pl"] == nil then
            -- common plural
            local subwords = mw.text.split(PAGENAME, "%s")
            local firstword = subwords[1]
            subwords[1] = mw.ustring.gsub(
                              "[[" .. firstword .. "]]-[[" .. firstword .. "]]",
                              "([a-z]+%-)%1%1", "%1") -- reduplicate only first word
            table.insert(pl, table.concat(subwords, " "))
            if script:getirKod() == "Arab" then
                -- reduplicated form in Jawi
                subwords[1] = mw.ustring.gsub(
                                  "[[" .. firstword .. "]][[۲#Malay|۲]]",
                                  "([a-z]+%-)%1%1", "%1") -- add "2" only first word
                table.insert(pl, table.concat(subwords, " "))
            end
        else
            table.insert(pl, args["pl"])
            if args["pl2"] then table.insert(pl, args["pl2"]) end
            if args["pl3"] then table.insert(pl, args["pl3"]) end
        end
        table.insert(data.cekimler, pl)
    end

    local ku = {etiket = "informal 1st possessive"}
    if args["ku"] ~= "-" or args["ku"] == nil then
        table.insert(data.cekimler, ku)
        if script:getirKod() == "Arab" then
            table.insert(ku, mw.ustring.format("%s[[-کو|کو]]", PAGENAME))
        else
            table.insert(ku, mw.ustring.format("%s[[-ku|ku]]", PAGENAME))
        end
    end

    local mu = {etiket = "impolite 2nd possessive"}
    if args["mu"] ~= "-" or args["mu"] == nil then
        table.insert(data.cekimler, mu)
        if script:getirKod() == "Arab" then
            table.insert(mu, mw.ustring.format("%s[[-مو|مو]]", PAGENAME))
        else
            table.insert(mu, mw.ustring.format("%s[[-mu|mu]]", PAGENAME))
        end
    end

    local nya = {etiket = "3rd possessive"}
    if args["nya"] ~= "-" or args["nya"] == nil then
        table.insert(data.cekimler, nya)
        if script:getirKod() == "Arab" then
            table.insert(nya, mw.ustring.format("%s[[-ڽ|ڽ]]", PAGENAME))
        else
            table.insert(nya, mw.ustring.format("%s[[-nya|nya]]", PAGENAME))
        end
    end

end

pos_functions["özel adlar"] = function(args, data)

    local pl = {etiket = "plural"}
    -- not necessary to have plural(s)
    if args["pl"] then table.insert(pl, args["pl"]) end
    if args["pl2"] then table.insert(pl, args["pl2"]) end
    if args["pl3"] then table.insert(pl, args["pl3"]) end
    if #pl > 0 then table.insert(data.cekimler, pl) end

end

local aliases = {
    ['transitive (person)'] = 'trp',
    ['trans (person)'] = 'trp',
    ['transitive (object)'] = 'tro',
    ['trans (object)'] = 'tro',
    ['intransitive'] = 'in',
    ['intrans'] = 'in',
    ['intr'] = 'in',
    ['feeling'] = 'fl',
    ['feel.'] = 'fl'
}

pos_functions["eylemler"] = function(args, data)

    local tv = args["tv"] or ""
    tv = aliases[tv] or tv
    if tv ~= "" then
        if tv == "t" or tv == "tr" or tv == "tran" or tv == "transitive" then
            table.insert(data.cekimler, {etiket = "transitive"})
            table.insert(data.kategoriler, "Malay transitive verbs")
        end
        if tv == "i" or tv == "in" or tv == "intr" or tv == "intransitive" then
            table.insert(data.cekimler, {etiket = "intransitive"})
            table.insert(data.kategoriler, "Malay intransitive verbs")
        end
        if tv == "s" or tv == "st" or tv == "stat" or tv == "stative" then
            table.insert(data.cekimler, {etiket = "stative"})
            table.insert(data.kategoriler, "Malay stative verbs")
        end
    else
        table.insert(data.kategoriler, "Malay verbs without transitivity")
    end

end

pos_functions["ön adlar"] = function(args, data)

    local aform = {etiket = "used in the form"}
    for _, a in ipairs(args) do table.insert(aform, a) end
    if #aform > 0 then table.insert(data.cekimler, aform) 
    end
end

pos_functions["classifiers"] = function(args, data)

    local se = {etiket = "singular"}
    if args["se"] ~= "-" or args["se"] == nil then
        table.insert(data.cekimler, se)
        if script:getirKod() == "Arab" then
            table.insert(se, mw.ustring.format("[[سي%]]", PAGENAME))
        else
            table.insert(se, mw.ustring.format("[[se%s]]", PAGENAME))
        end
    end
end

return export