Modul:pi-headword
A modult a Modul:pi-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('pi')
local PAGENAME = mw.title.getCurrentTitle().text
local currentScript = require('Module:scripts').findBestScript(PAGENAME, lang)
local translit = require('Module:pi-Latn-translit').tr
local Array = require "Module:array"
function export.alt(frame)
local args = frame:getParent().args
local currentScriptCode = currentScript:getCode()
local availableScripts = lang:getScripts()
local latinForm = args['Latn'] or currentScriptCode == 'Latn' and PAGENAME or error('No Latin-script form detected.')
local scriptCode
local terms
local first
local output = Array('<div class="NavFrame" style="max-width:40em"><div class="NavHead" style="background:#d9ebff">Alternative forms</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'], args[scriptCode..'4'] }
output:insert('<li>')
local t1, t2, t3
t1 = translit(latinForm, scriptCode) -- not affect Latn itself
if scriptCode == 'Thai' or scriptCode == 'Laoo' then
t2 = translit(latinForm, scriptCode, {impl='no'})
end
-- For Lao script without implicit vowels, 'y' can also be 'ຢ', but seemingly
-- not if a Buddhist Institute consonant is used.
if scriptCode == 'Laoo' then
if not mw.ustring.find(t2, '[ຆຌຏຐຑຒຓຘຠຨຩ]') then
t3 = mw.ustring.gsub(t2, 'ຍ', 'ຢ')
end
end
if #terms == 0 then
terms[1] = t1
if t2 and t1 ~= t2 then terms[2] = t2 end
if t3 and (t2 ~= t3) then table.insert(terms, t3) end
elseif terms[1] ~= t1 and terms[2] ~= t1 and terms[3] ~= t1 and terms[4] ~= t1 then
output:insert('[[Category:Pali terms with inconsistent transliterations]]')
end
first = true
for _,term in ipairs(terms) do
if term ~= nil and term ~= PAGENAME then
if first then
output:insert(links.full_link({lang = lang, sc = script, term = term}))
first = false
else
output:insert(' or ' .. links.full_link({lang = lang, sc = script, term = term}))
end
end
end
if scriptCode ~= currentScriptCode or #terms > 1 then
output:insert(' ' .. labels.show_labels({ script:getCategoryName() }, lang) .. '</li>')
end
end
output:insert('</ul></div></div>')
return output:concat()
end
function export.show(frame)
local args = require('Module:parameters').process(frame:getParent().args,{
[1] = {default = '?'},
["g2"] = {},
['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 = {'Pali ' .. 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])
table.insert(data.genders, args["g2"])
end
if poscat == 'verbs' then
table.insert(data.inflections, {label = 'root', args[1]})
end
return require('Module:headword').full_headword(data)
end
return export