Module:bar-pron

local export = {}

local PAGENAME = mw.title.getCurrentTitle.text

-- If Not Empty local function ine(arg) if arg == "" then return nil else return arg end end

local function gettra(text) local repl1 = { ['é'] = 'e', ['ó'] = 'o', ['ĩ'] = 'î', ['õ'] = 'ô', ['ũ'] = 'û' }	for key,value in pairs(repl1) do		text = mw.ustring.gsub(text, key, value) text = mw.ustring.gsub(text, mw.ustring.upper(key), mw.ustring.upper(value)) end text = mw.ustring.gsub(text, '([eiouèòEIOUÈÒ])a', '%1ă') return text end

local function getipa(text) local divow = 'äöüàèòåâêîôûãẽ'	-- all vowels with diacritics local ltr = 'a-zß'..divow..'̯'	-- all letters text = mw.ustring.lower(text) text = '␂' .. text .. '␃'	-- mark start and end of text text = mw.ustring.gsub(text, '([aeiou'..divow..'])%1', '%1ː')	-- long vowels -- diphthongs text = mw.ustring.gsub(text, '([eiouèò])[aă]', '%1ɐ̯') text = mw.ustring.gsub(text, '([aeiouäöàèòå][iu])', '%1̯') -- initial replacements local replini1 = { ['bh'] = 'pʰ', ['dh'] = 'tʰ', ['gh'] = 'kʰ', ['k'] = 'kʰ' }	for key,value in pairs(replini1) do		text = mw.ustring.gsub(text, '([^'..ltr..'])'..key..'([aeiou'..divow..'])', '%1'..value..'%2') end local replini2 = { ['sp'] = 'ʃp', ['st'] = 'ʃt' }	for key,value in pairs(replini2) do		text = mw.ustring.gsub(text, '([^'..ltr..'])'..key, '%1'..value) end -- universal replacements local repl1 = { ['ã'] = 'ɒ̃', ['ẽ'] = 'æ̃', ['äö'] = 'ɶː', ['ck'] = 'kk', ['ng'] = 'ŋ', ['nk'] = 'ŋk', ['([eèiöü])ch'] = '%1ç', ['kch'] = 'k͡χ', ['pf'] = 'p͡f', ['sch'] = 'ʃ' }	for key,value in pairs(repl1) do		text = mw.ustring.gsub(text, key, value) end -- universal replacements local repl2 = { ['ä'] = 'æ', ['à'] = 'a', ['å'] = 'ɒ', ['ă'] = 'ɐ', ['è'] = 'ɛ', ['ò'] = 'ɔ', ['ö'] = 'œ', ['ü'] = 'y', ['â'] = 'ã', ['ê'] = 'ẽ', ['î'] = 'ĩ', ['ô'] = 'õ', ['û'] = 'ũ', ['ch'] = 'x', ['v'] = 'f', ['w'] = 'β', ['z'] = 't͡s', ['b'] = 'b̥', ['d'] = 'd̥', ['g'] = 'ɡ̊', ['ß'] = 's'	} for key,value in pairs(repl2) do		text = mw.ustring.gsub(text, key, value) end text = mw.ustring.gsub(text, '[␂␃]', '')	-- remove start/end marks return text end

function export.show(frame) -- get arguments local args = frame:getParent.args local tra = {} local ipa = {} local qual = {} tra[1] = args[1] or PAGENAME tra[1] = gettra(tra[1]) ipa[1] = args['ipa'] or args['ipa1'] or getipa(tra[1]) qual[1] = args['q'] or args['q1'] or nil local i = 2 while ine(args[i]) do		tra[i] = gettra(args[i]) ipa[i] = args['ipa'..i] or getipa(tra[i]) qual[i] = args['q'..i] or nil i = i + 1 end text = ' ' return text end

return export