Modül:de-ad
Bu belgeleme Modül:de-ad/belge (düzenle | geçmiş) sayfasından yansıtılmaktadır. Arayüz düzenleyicilerinin deney yapabilmeleri için ayrıca Modül:de-ad/deneme tahtası sayfası kullanılabilir.
local m_baglantilar = require("Modül:bağlantılar")
local m_utils = require("Modül:araçlar")
local lang = require("Modül:diller").getirKodaGore("de")
local export = {}
local decls = {}
local archaic_dative_note = "Şimdilerde yaygın değil, [[Vikisözlük:Almanca madde esasları|notlara bakın]]"
PAGENAME = mw.title.getCurrentTitle().text or ''
local function join_ending(stem, ending, s)
return ((s and mw.ustring.gsub(stem, "ß$", "ss")) or stem) .. ending
end
local function make_plural(pl, head, suffix, s)
return pl or suffix == '-' and '-' or join_ending(head, suffix, s)
end
local function get_dat_pl(pl)
return pl .. (mw.ustring.match(pl, "[erl]$") and 'n' or '')
end
decls.m = {
params = {
[1] = {},
[2] = {default = ''},
["pl"] = {},
["ns"] = {},
["gs"] = {},
["ds"] = {},
["as"] = {},
["bs"] = {},
["vs"] = {},
["np"] = {},
["gp"] = {},
["dp"] = {},
["ap"] = {},
["n"] = {default = "tam"},
["prop"] = {type = "boolean", default = false},
["ss"] = {type = "boolean", default = false},
["notes"] = {},
},
}
setmetatable(decls.m, {__call = function(self, args, data)
data.forms["ns"] = {data.head}
if args[1] == nil then
data.forms["gs"] = {data.head}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "n" or args[1] == "ns" then
data.forms["gs"] = {join_ending(data.head, args[1], args.ss)}
data.forms["ds"] = {join_ending(data.head, 'n', args.ss)}
data.forms["as"] = {join_ending(data.head, 'n', args.ss)}
elseif args[1] == "en" or args[1] == "ens" then
data.forms["gs"] = {join_ending(data.head, args[1], args.ss)}
data.forms["ds"] = {join_ending(data.head, 'en', args.ss)}
data.forms["as"] = {join_ending(data.head, 'en', args.ss)}
elseif args[1] == "s" then
data.forms["gs"] = {join_ending(data.head, 's', args.ss)}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "es" then
data.forms["gs"] = {join_ending(data.head, 'es', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'e', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "ses" then
data.forms["gs"] = {join_ending(data.head, 'ses', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'se', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "(e)s" then
data.forms["gs"] = {join_ending(data.head, 'es', args.ss), join_ending(data.head, 's', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'e', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "(s)" then
data.forms["gs"] = {join_ending(data.head, 's', args.ss), data.head}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "'" then
data.forms["gs"] = {join_ending(data.head, "'", args.ss)}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "{{{1}}}" and mw.title.getCurrentTitle().nsText == "Şablon" then
data.forms["gs"] = {data.head .. args[1]}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
else
error('İlk parametre “' .. tostring(args[1]) .. '” tanınamadı.')
end
local pl = make_plural(args.pl, data.head, args[2], args.ss)
data.forms["np"] = {pl}
data.forms["gp"] = {pl}
data.forms["dp"] = {get_dat_pl(pl)}
data.forms["ap"] = {pl}
data.articles = {
art_ind_ns = "ein", art_def_ns = "der", art_pl_np = "die",
art_ind_gs = "eines", art_def_gs = "des", art_pl_gp = "der",
art_ind_ds = "einem", art_def_ds = "dem", art_pl_dp = "den",
art_ind_as = "einen", art_def_as = "den", art_pl_ap = "die",
art_ind_bs = "einen", art_def_bs = "den", art_pl_bp = "?",
art_ind_vs = "einen", art_def_vs = "den", art_pl_vp = "?",
}
end
})
decls.n = {
params = {
[1] = {},
[2] = {default = ''},
["pl"] = {},
["ns"] = {},
["gs"] = {},
["ds"] = {},
["as"] = {},
["bs"] = {},
["vs"] = {},
["np"] = {},
["gp"] = {},
["dp"] = {},
["ap"] = {},
["n"] = {default = "tam"},
["prop"] = {type = "boolean", default = false},
["ss"] = {type = "boolean", default = false},
["notes"] = {},
},
}
setmetatable(decls.n, {__call = function(self, args, data)
data.forms["ns"] = {data.head}
if args[1] == nil then
data.forms["gs"] = {data.head}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "s" then
data.forms["gs"] = {join_ending(data.head, 's', args.ss)}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "es" then
data.forms["gs"] = {join_ending(data.head, 'es', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'e', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "ses" then
data.forms["gs"] = {join_ending(data.head, 'ses', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'se', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "(e)s" then
data.forms["gs"] = {join_ending(data.head, 'es', args.ss), join_ending(data.head, 's', args.ss)}
data.forms["ds"] = {data.head, join_ending(data.head, 'e', args.ss), notes = {[2] = archaic_dative_note}}
data.forms["as"] = {data.head}
elseif args[1] == "(s)" then
data.forms["gs"] = {join_ending(data.head, 's', args.ss), data.head}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "ens" then
data.forms["gs"] = {join_ending(data.head, 'ens', args.ss)}
data.forms["ds"] = {join_ending(data.head, 'en', args.ss), data.head}
data.forms["as"] = {data.head}
elseif args[1] == "n" then
data.forms["gs"] = {join_ending(data.head, 'n', args.ss)}
data.forms["ds"] = {join_ending(data.head, 'n', args.ss)}
data.forms["as"] = {data.head}
elseif args[1] == "'" then
data.forms["gs"] = {join_ending(data.head, "'", args.ss)}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
elseif args[1] == "{{{1}}}" and mw.title.getCurrentTitle().nsText == "Şablon" then
data.forms["gs"] = {join_ending(data.head, args[1], args.ss)}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
else
error('İlk parametre “' .. tostring(args[1]) .. '” tanınamadı.')
end
local pl = make_plural(args.pl, data.head, args[2], args.ss)
data.forms["np"] = {pl}
data.forms["gp"] = {pl}
data.forms["dp"] = {get_dat_pl(pl)}
data.forms["ap"] = {pl}
data.articles = {
art_ind_ns = "ein", art_def_ns = "das", art_pl_np = "die",
art_ind_gs = "eines", art_def_gs = "des", art_pl_gp = "der",
art_ind_ds = "einem", art_def_ds = "dem", art_pl_dp = "den",
art_ind_as = "ein", art_def_as = "das", art_pl_ap = "die",
art_ind_bs = "ein", art_def_bs = "das", art_pl_bp = "?",
art_ind_vs = "ein", art_def_vs = "das", art_pl_vp = "?",
}
end
})
decls.f = {
params = {
[1] = {default = ''},
["pl"] = {},
["ns"] = {},
["gs"] = {},
["ds"] = {},
["as"] = {},
["bs"] = {},
["vs"] = {},
["np"] = {},
["gp"] = {},
["dp"] = {},
["ap"] = {},
["n"] = {default = "tam"},
["prop"] = {type = "boolean", default = false},
["ss"] = {type = "boolean", default = false},
["notes"] = {},
},
}
setmetatable(decls.f, {__call = function(self, args, data)
data.forms["ns"] = {data.head}
data.forms["gs"] = {data.head}
data.forms["ds"] = {data.head}
data.forms["as"] = {data.head}
local pl = make_plural(args.pl, data.head, args[1], args.ss)
data.forms["np"] = {pl}
data.forms["gp"] = {pl}
data.forms["dp"] = {get_dat_pl(pl)}
data.forms["ap"] = {pl}
data.articles = {
art_ind_ns = "eine", art_def_ns = "die", art_pl_np = "die",
art_ind_gs = "einer", art_def_gs = "der", art_pl_gp = "der",
art_ind_ds = "einer", art_def_ds = "der", art_pl_dp = "den",
art_ind_as = "eine", art_def_as = "die", art_pl_ap = "die",
art_ind_bs = "eine", art_def_bs = "die", art_pl_bp = "?",
art_ind_vs = "eine", art_def_vs = "die", art_pl_vp = "?",
}
end
})
decls.pl = {
params = {
["np"] = {},
["gp"] = {},
["dp"] = {},
["ap"] = {},
["prop"] = {type = "boolean", default = false},
["notes"] = {},
},
}
setmetatable(decls.pl, {__call = function(self, args, data)
local pl = data.head
data.forms["np"] = {pl}
data.forms["gp"] = {pl}
data.forms["dp"] = {get_dat_pl(pl)}
data.forms["ap"] = {pl}
data.articles = {
art_pl_np = "die",
art_pl_gp = "der",
art_pl_dp = "den",
art_pl_ap = "die",
}
end
})
local nums = {
['tam'] = {'ns', 'gs', 'ds', 'as', 'np', 'gp', 'dp', 'ap'},
['sg'] = {'ns', 'gs', 'ds', 'as'},
['pl'] = {'np', 'gp', 'dp', 'ap'},
['sg-av'] = {'ns', 'gs', 'ds', 'as', 'bs', 'vs'},
}
local function make_forms(args, data, num)
if num == 'sg' then
table.insert(data.title_app, "''sayılamayan''")
elseif num == 'pl' then
table.insert(data.title_app, "''sadece çoğul''")
elseif num == 'sg-av' then
table.insert(data.title_app, "''Latin kökenli''")
table.insert(data.categories, lang:getirAsilAd() .. ' Latin çekimli adlar')
end
if args.prop then
table.insert(data.title_app, "''özel ad''")
end
if #data.title_app > 0 then
data.output.title_app = ' (' .. table.concat(data.title_app, ', ') .. ')'
else
data.output.title_app = ''
end
local note_num = 1
local found_red_link = false
for _, case in ipairs(nums[num]) do
terms = args[case] ~= nil and mw.text.split(args[case], '/') or data.forms[case] or {}
local notes = terms.notes or {}
for i, term in ipairs(terms) do
if mw.ustring.match(term, "^{{{") then
linked = term
elseif term == '-' then
linked = '—'
elseif term == '~' then
linked = m_baglantilar.tam_bag({dil = lang, alt = m_baglantilar.kaldir_baglantilari(data.forms['n' .. mw.ustring.sub(case, -1)][1])})
elseif data.seen_forms[term] then
linked = m_baglantilar.tam_bag({dil = lang, alt = term})
else
linked = m_baglantilar.tam_bag({dil = lang, sozcuk = term})
data.seen_forms[term] = true
if not found_red_link and not mw.title.new(lang:yapGirdiAdi(term)).exists then
found_red_link = true
end
end
if notes[i] then
linked = linked .. '<sup>' .. tostring(note_num) .. '</sup>'
table.insert(data.notes, '<sup>' .. tostring(note_num) .. '</sup>' .. notes[i])
note_num = note_num + 1
end
terms[i] = linked
end
data.output[case] = table.concat(terms, ',<br/>')
end
if args.notes then
table.insert(data.notes, args.notes)
end
data.output.notes = table.concat(data.notes)
data.output.notes = data.output.notes ~= '' and '<div style="text-align:left; font-style: italic;">' .. data.output.notes .. '</div>' or ''
if found_red_link then
table.insert(data.categories, lang:getirAsilAd() .. ' çekimleme tablolarında kırımızı bağlantı olan adlar')
end
for name, art in pairs(data.articles) do
data.output[name] = (args.prop == true and '(' .. art .. ')') or art
end
data.output.title = data.output[nums[num][1]]
end
local function make_table(args, data, wikicode, num)
make_forms(args, data, num)
local function repl(param)
return data.output[param]
end
return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl) .. m_utils.format_categories(data.categories, lang)
end
function export.show(frame)
local parent_args = frame:getParent().args
local decl_type = frame.args[1] or ''
if not decls[decl_type] then
error("Bilinmeyen çekim: '" .. tostring(decl_type) .. "'")
end
if mw.title.getCurrentTitle().nsText ~= "" then
decls[decl_type].params.head = {default = PAGENAME}
end
local args = require("Modül:parameters").process(parent_args, decls[decl_type].params)
local seen_forms = {}
local data = {
forms = {},
seen_forms = {[PAGENAME] = true},
head = args.head or PAGENAME,
notes = {},
title_app = {},
output = {},
categories = {},
articles = {},
}
local num = args.n
if decl_type == 'pl'then
num = 'pl'
elseif args.bs or args.vs then
num = 'sg-av'
end
if args[1] == '-' or args[2] == '-' then
error('"-" kullanımı bu şablonda geçersizdir. Please use “n=sg” if the noun is singular only or “n=pl” if plural only.')
end
if (not args[1] or args[1] == "") and mw.title.getCurrentTitle().nsText == "Şablon" then
setmetatable(args, {__index = function(self, key)
return "{{{" .. key .. "}}}"
end
})
end
-- Generate the forms
decls[decl_type](args, data)
data.decl = decl_type
local wikicode = frame:expandTemplate{title= 'de-ad-tablo-' .. num, args = {}}
return make_table(args, data, wikicode, num)
end
return export