Module:User:SarahFatimaK/tengwar

local export = {}

local PAGENAME = mw.title.getCurrentTitle.text

function export.show(frame) -- get arguments local args = frame:getParent.args local lang = frame.args[1] or error("Language code has not been specified.") local text = frame.args[2] or PAGENAME local font = frame.args[3] or 'annatar' -- prepare arguments text = mw.ustring.lower(text) text = mw.ustring.gsub(text, 'appendix:[^/]+/', '')	-- remove Appendix:/ if lang == 'qya' then	-- Quenya -- merge duplicate transcriptions local dublfind = {'ks', 'kw', 'nw', 'th', 'j', 'k', 'â', 'ê', 'î', 'ô', 'û', 'ë'} local duplrepl = {'x', 'qu', 'ñw', 'þ', 'y', 'c', 'á', 'é', 'í', 'ó', 'ú', 'e'} for i=1, #dublfind do			text = mw.ustring.gsub(text, dublfind[i], duplrepl[i]) end -- define arrays for conversion local arfind = {'ngw', 'nqu', 'cc', 'hl', 'hr', 'hw', 'hy', 'ld', 'll', 'ly', 'mb', 'mm', 'mp', 'nc', 'nd', 'ng', 'nn', 'nt', 'ñw', 'ny', 'pp', 'ps', 'qu', 'rd', 'rr', 'ss', 'tt', 'ty', 'c', 'f', 'h', 'l', 'm', 'n', 'ñ', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'þ', 'ai', 'au', 'eu', 'iu', 'oi', 'ui', 'á', 'é', 'í', 'ó', 'ú', 'a', 'e', 'i', 'o', 'u'} local repltel = {'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''} local replana = {'x', 'v', 'a\, '½j', '½7', 'c', '9Ï', 'm', 'j¸', 'j´', 'w', 't"', 'r', 'f', '2', 's', '5"', '4', 'b', '5Ì', 'q\, 'q\+', 'z', 'u', '7\, 'k', '1\, '1Í', 'a', 'e', 'd', 'j', 't', '5', 'g', 'q', '6', '8', '1', 'y', 'n', 'aå', 'hÍ', '3', 'lE', '.D', '.F', '.G', 'lY', 'lU', '~C', '~V', '~B', '~N', '~M', 'E', 'R', 'T', 'Y', 'U', '<', '9', '7', 'i'} -- detect vowel onsets text = mw.ustring.gsub(text, '(^|[^bcdfghjklmnpqrstvwxyzñþ])([aou]i|[aei]u|[aeiou])', '`%1%2') -- convert to Telcontar (base font, as it uses own codepoints) for i=1, #arfind do			text = mw.ustring.gsub(text, arfind[i], repltel[i]) end -- switch consonants, that have another form before vowels local cons2find = {'', '', '', ''} local cons2repl = {'', '', '', ''} for i=1, #cons2find do			text = mw.ustring.gsub(text, cons2find[i]..'([])', cons2repl[i]..'%1') end if font == 'annatar' then	-- covert to Annatar for i=1, #repltel do				text = mw.ustring.gsub(text, repltel[i], replana[i]) end local vowdef = {'E', 'R', 'T', 'Y', 'U'} local vowwide = {'#' ,'\$', '%', '\^', '&'} local vowround = {'D' ,'F', 'G', 'H', 'J'} local vownarr = {'C' ,'V', 'B', 'N', 'M'} -- adjust diacritics to the letter width for i=1, #vowdef do				text = mw.ustring.gsub(text, '([245bfgjrstwx][\'"´ÍÌÏ]?)'..vowdef[i], '%1'..vowwide[i])				text = mw.ustring.gsub(text, '([9e~`][\'"´ÍÌÏ]?)'..vowdef[i], '%1'..vownarr[i]) text = mw.ustring.gsub(text, '([ei,.][\'"´ÍÌÏ]?)'..vowdef[i], '%1'..vowround[i])			end		end	else		error("Language code is not supported.")	end	return text end

return export