Modul:sa-headword
A modult a Modul:sa-headword/doc lapon tudod dokumentálni
local export = {}
local pos_functions = {}
local links = require('Module:links')
local labels = require('Module:labels')
local lang = require('Module:languages').getByCode('sa')
local PAGENAME = mw.title.getCurrentTitle().text
local currentScript = require('Module:scripts').findBestScript(PAGENAME, lang)
local translit = require('Module:sa-convert').tr
function export.alt(frame)
local args = frame:getParent().args
local currentScriptCode = currentScript:getCode()
local availableScripts = lang:getScripts()
local devaForm = currentScriptCode == 'Deva' and PAGENAME or args['Deva'] or error('No Devanagari-script form detected.')
local scriptCode
local terms
local first
local output = '<div class="NavFrame" style="max-width:40em"><div class="NavHead" style="background:#d9ebff">Alternative scripts</div><div class="NavContent" style="text-align:left"><ul>'
for _,script in ipairs(availableScripts) do
scriptCode = script:getCode()
terms = { args[scriptCode], args[scriptCode..'2'], args[scriptCode..'3'] }
output = output .. '<li>'
if scriptCode ~= 'Deva' then
if #terms == 0 then
terms[1] = translit(devaForm, scriptCode)
elseif terms[1] ~= translit(devaForm, scriptCode) then
output = output .. '[[Category:Sanskrit terms with inconsistent transliterations]]'
end
end
if terms[1] ~= "" then
first = true
for _,term in ipairs(terms) do
if term ~= nil and term ~= PAGENAME then
if first then
output = output .. links.full_link({lang = lang, sc = script, term = term, tr = "-"})
first = false
else
output = output .. ' or ' .. links.full_link({lang = lang, sc = script, term = term, tr = "-"})
end
end
end
if scriptCode ~= currentScriptCode then
output = output .. ' ' .. labels.show_labels({ script:getCategoryName() }, lang) .. '</li>'
end
end
end
output = output .. '</ul></div></div>'
return output
end
function export.show(frame)
local args = require('Module:parameters').process(frame:getParent().args,{
[1] = {default = '?'},
['head'] = {},
})
local poscat = frame.args[1] or error('Part of speech has not been specified. Please pass parameter 1 to the module invocation.')
local data = {lang = lang, sc = currentScript, pos_category = poscat, categories = {'Sanskrit ' .. poscat .. ' in ' .. currentScript:getCategoryName()}, heads = {args['head'] or PAGENAME}, genders = {}, inflections = {}}
if poscat == 'nouns' or poscat == 'proper nouns' or poscat == 'pronouns' then
table.insert(data.genders, args[1])
end
if poscat == 'verbs' then
table.insert(data.inflections, {label = 'root', args[1]})
end
return require('Module:headword').full_headword(data)
end
return export