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

local export = {}

local PAGENAME = mw.title.getCurrentTitle().text

function export.convert2(frame)
	local text = frame:getParent().args[1] or PAGENAME
	return export.convert(text)
end

function export.convert(text)	
	-- merge duplicate transcriptions (replaced by the easier processable one)
	local dublfind = {'H', 'Q', '\''}
	local duplrepl = {'x', 'qh', 'ʼ'}
	
	for i=1, #dublfind do
		text = mw.ustring.gsub(text, dublfind[i], duplrepl[i])
	end
	
	text = mw.ustring.lower(text)
	text = mw.ustring.gsub(text, '%[%[.*%|', '')
	text = mw.ustring.gsub(text, '[%[%]]', '')
	text = mw.ustring.gsub(text, 'appendix:[^/]+/', '')	-- remove Appendix:<Language>/
	
	-- define arrays for conversion
	local arrepl1 = {
		['tlh'] = '', ['ch'] = '', ['gh'] = '', ['ng'] = '', ['qh'] = '' -- capital Q
	}
	local arrepl2 = {
		['x'] = '', -- capital H
		['a'] = '', ['e'] = '', ['i'] = '', ['o'] = '', ['u'] = '',
		['b'] = '', ['d'] = '', ['j'] = '', ['l'] = '', ['m'] = '',
		['n'] = '', ['p'] = '', ['q'] = '', ['r'] = '', ['s'] = '',
		['t'] = '', ['v'] = '', ['w'] = '', ['y'] = '', ['ʼ'] = '',
		['0'] = '', ['1'] = '', ['2'] = '', ['3'] = '', ['4'] = '',
		['5'] = '', ['6'] = '', ['7'] = '', ['8'] = '', ['9'] = '',
		[','] = '', ['\\.'] = ''
	}
	
	-- convert to pIqaD
	for key,value in pairs(arrepl1) do
		text = mw.ustring.gsub(text, key, value)
	end
	for key,value in pairs(arrepl2) do
		text = mw.ustring.gsub(text, key, value)
	end

	return text
end

return export