Module:pi-headword

Hello, you have come here looking for the meaning of the word Module:pi-headword. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:pi-headword, but we will also tell you about its etymology, its characteristics and you will know how to say Module:pi-headword in singular and plural. Everything you need to know about the word Module:pi-headword you have here. The definition of the word Module:pi-headword will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:pi-headword, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}
local pos_functions = {}
local links = require('Module:links')
local labels = require('Module:labels')

local m_lang = require('Module:languages')
local lang = m_lang.getByCode('pi')
local langmul
local PAGENAME = mw.title.getCurrentTitle().text

local translit = require('Module:pi-Latn-translit').tr
local Array = require "Module:array"
local ti = table.insert

function export.alt(frame)

	local args = frame:getParent().args

	local currentScript = lang:findBestScript(PAGENAME)
	local currentScriptCode = currentScript:getCode()
	local availableScripts = lang:getScripts()
	local latinForm = args or currentScriptCode == 'Latn' and PAGENAME or error('No Latin-script form detected.')
	local scriptCode

	local terms, langs
	local first
	local ltrlang = {Latn = 'mul', Brah = 'mul', Deva = 'mul', Beng = 'mul', Sinh = 'mul',
					 Mymr = 'mul', Thai = 'pi',  Lana = 'mul', Laoo = 'mul', Khmr = 'pi',
					 Cakm = 'mul'}
	local output = Array('<div class="NavFrame" style="max-width:40em"><div class="NavHead" style="background:var(--wikt-palette-lightblue,#d9ebff);color:inherit">Alternative scripts</div><div class="NavContent" style="text-align:left"><ul>')
	local deflang
	local function lfrom(ord)
		local namels = {}
		ti(namels, scriptCode)
		ti(namels, 'lang')
		ti(namels, ord)
		return args or deflang
	end
	for _, script in ipairs(availableScripts) do
		scriptCode = script:getCode()
		if args ~= '-' then
			deflang = (args.letter == '1' or args.letter == 1) and
						(ltrlang or 'mul')
					or 'pi'
			terms = { args, args, args,
				 args, args, args,
				 args, args}
			langs =    {lfrom(''), lfrom('2'), lfrom('3'),
						lfrom('4'), lfrom('5'), lfrom('6'),
						lfrom('7'), lfrom('8')}
			if args.hl1 and scriptCode == 'Latn' then -- Discard argument 'Latn'
				terms = {terms, terms, terms, terms, terms, terms, terms}
				langs = {langs, langs, langs, langs, langs, langs, langs}
			end
			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 = t1
				if t2 and (t1 ~= t2) then ti(terms, t2) end
				if t3 and (t1 ~= t3) and (t2 ~= t3) then ti(terms, t3) end
				if t4 and (t1 ~= t4) and (t2 ~= t4) and (t3 ~= t4) then ti(terms, t4) end
				for k = 1, 4 do langs = deflang end
			elseif terms ~= t1 and terms ~= t1  and terms ~= t1  and terms ~= t1 then
				output:insert(']')
			end

			first = true
			for k, term in ipairs(terms) do
				if term ~= nil and term ~= PAGENAME then
					if first then
						first = false
						output:insert('<li>')
					else
						output:insert(' or ')
					end
					local langobj
					if langs == 'pi' then
						langobj = lang
					elseif langs == 'mul' then
						langmul = langmul or m_lang.getByCode('mul')
						langobj = langmul
					else
						langobj = m_lang.getByCode(langs)
					end
					output:insert(links.full_link({lang = langobj, sc = script, term = term, tr = '-'}))
				end
			end
			if not first then
				output:insert(' ' .. labels.show_labels {
					lang = lang,
					labels = { script:getDisplayForm() },
				} .. '</li>')
			end
	
		end
	end
	output:insert('</ul></div></div>')

	return output:concat()

end

function export.show(frame)
	local params = {
		 = {list = true},
		 = {list = true, allow_holes = true, default = "-"},
	}
	local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	local is_noun
	if poscat == "nouns" or poscat == "proper nouns" or poscat == "pronouns" or poscat == "noun forms" then
		is_noun = true
		params = {list = "g", default = "?"}
		params = {list = true}
		params = {list = true}
		params = {list = true}
	end
	if poscat == "verbs" then
		params = {default = "?"}
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	for i, v in ipairs(args.tr) do
		if args.tr == '+' then args.tr = nil end
	end

	local genders = {}
	if is_noun then
		genders = args
	end

	local data = {lang = lang, pos_category = poscat, categories = {},
		sccat = true, heads = args.heads, genders = genders, inflections = {}, translits = args.tr
	}
	
	if is_noun then
		if #args.m > 0 then
			args.m.label = "masculine"
			table.insert(data.inflections, args.m)
		end
		if #args.f > 0 then
			args.f.label = "feminine"
			table.insert(data.inflections, args.f)
		end
		if #args.n > 0 then
			args.n.label = "neuter"
			table.insert(data.inflections, args.n)
		end
		if #args.m > 0 or #args.f > 0 or #args.n > 0 then
			table.insert(data.categories, "Pali nouns with other-gender equivalents")
		end
	end
    if poscat == "verbs" then
        table.insert(data.inflections, {label = "root", args})
    end
	
	return require("Module:headword").full_headword(data)
end

return export