local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
function export.show(frame)
-- get arguments
local args = frame:getParent().args
local lang = frame.args or error("Language code has not been specified.")
local text = frame.args or PAGENAME
local font = frame.args or 'annatar'
-- prepare arguments
text = mw.ustring.lower(text)
text = mw.ustring.gsub(text, 'appendix:+/', '') -- remove Appendix:<Language>/
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, duplrepl)
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, '(^|)(i|u|)', '`%1%2')
-- convert to Telcontar (base font, as it uses own codepoints)
for i=1, #arfind do
text = mw.ustring.gsub(text, arfind, repltel)
end
-- switch consonants, that have another form before vowels
local cons2find = {'', '', '', ''}
local cons2repl = {'', '', '', ''}
for i=1, #cons2find do
text = mw.ustring.gsub(text, cons2find..'()', cons2repl..'%1')
end
if font == 'annatar' then -- covert to Annatar
for i=1, #repltel do
text = mw.ustring.gsub(text, repltel, replana)
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, '(?)'..vowdef, '%1'..vowwide)
text = mw.ustring.gsub(text, '(?)'..vowdef, '%1'..vownarr)
text = mw.ustring.gsub(text, '(?)'..vowdef, '%1'..vowround)
end
end
else
error("Language code is not supported.")
end
return text
end
return export