Module:Pi-headword

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(' Alternative forms ') for _, script in ipairs(availableScripts) do		scriptCode = script:getCode terms = { args[scriptCode], args[scriptCode..'2'], args[scriptCode..'3'], args[scriptCode..'4'] }

output:insert('')

local t1, t2, t3, t4		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 scriptCode == 'Mymr' then t2 = translit(latinForm, scriptCode, {variation='1'}) --Mon t3 = translit(latinForm, scriptCode, {variation='2'}) --Old Shan t4 = translit(latinForm, scriptCode, {variation='3'}) --New Shan end

if #terms == 0 then terms[1] = t1			if t2 and (t1 ~= t2) then table.insert(terms, t2) end if t3 and (t1 ~= t3) and (t2 ~= t3) then table.insert(terms, t3) end if t4 and (t1 ~= t4) and (t2 ~= t4) and (t3 ~= t4) then table.insert(terms, t4) end elseif terms[1] ~= t1 and terms[2] ~= t1 and terms[3] ~= t1  and terms[4] ~= t1 then output:insert('') 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) .. '') end end output:insert(' ')

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