local p =
function p._encoding(s, ipaNum, xSampa, tipa, praat, keyman, braille) local data = mw.loadData('Module:Sandbox/Nardog/10d') local conv = require('Module:BaseConvert').convert -- Decode HTML entities and strip dotted circle s = mw.ustring.gsub(mw.text.decode(s), '◌', ) local hex, dec =, -- Initialize tables unless manually input local newIpaNum = not ipaNum and local newXSampa = not xSampa and local newTipa = not tipa and local newPraat = not praat and local newKeyman = not keyman and local newBraille = not braille and local xSampaVars -- Tracks X-SAMPA variants local keymanVars -- Tracks Keyman variants local tipaTies -- Tracks tie bars for TIPA for char in mw.text.gsplit(s, ) do table.insert(dec, mw.ustring.codepoint(char)) table.insert(hex, conv) -- Skip others if all are manually input or have reached a dead end if newIpaNum or newXSampa or newTipa or newPraat or newKeyman or newBraille then local t = data[char] if t then -- Table found in data if newIpaNum then if t.ipaNum then table.insert(newIpaNum, t.ipaNum) else newIpaNum = nil end end if newXSampa then if t.xSampa then -- Check for variants if type(t.xSampa)
'͡' then -- Record the position tipaTies = tipaTies or table.insert(tipaTies, #newTipa) else newTipa = nil end end if newPraat then if t.praat then table.insert(newPraat, t.praat) else newPraat = nil end end if newKeyman then if t.keyman then -- Check for variants if type(t.keyman)
',
'
or ')
else
xSampa = table.concat(newXSampa)
end
end
if tipaTies then
for _, pos in ipairs(tipaTies) do
-- Wrap two letters in "\t{...}"
newTipa[pos] = '\\t{' .. newTipa[pos]
newTipa[pos + 1] = newTipa[pos + 1] .. '}'
end
end
tipa = tipa or newTipa and newTipa[1] and table.concat(newTipa)
praat = praat or newPraat and newPraat[1] and table.concat(newPraat)
if not keyman and newKeyman and newKeyman[1] then
-- Check for variants
if keymanVars then
local newKeymans = { newKeyman }
-- Go through each char with variants
for char, _ in pairs(keymanVars) do
local newKeymans2 = {}
-- Go through each variant
for i, variant in ipairs(data[char].keyman) do
if i ~= 1 then -- Skip the 1st, already used
-- Go through each string (stored as a table)
for _, t in ipairs(newKeymans) do
local t2 = mw.clone(t)
-- Go through each position of variant to replace
for _, pos in ipairs(keymanVars[char]) do
t2[pos] = variant
end
table.insert(newKeymans2, t2)
end
end
end
for _, t in ipairs(newKeymans2) do
table.insert(newKeymans, t)
end
end
keyman = {}
for _, v in ipairs(newKeymans) do
table.insert(keyman, mw.text.nowiki(table.concat(v)))
end
keyman = mw.text.listToText(keyman, '
, ',
'
or ')
else
keyman = mw.text.nowiki(table.concat(newKeyman))
end
end
braille = braille and mw.text.split(braille, ',')
or newBraille and newBraille[1] and newBraille
s = mw.html.create
local function makeRow(label, data)
s:tag('tr')
:tag('th'):attr('scope', 'row'):wikitext(label):done
:tag('td'):wikitext(data)
end
makeRow('[[Unicode]] (hex)', 'U+' .. table.concat(hex, ' U+'))
makeRow('Unicode (decimal)', table.concat(dec, ' '))
if ipaNum and ipaNum ~= 'hide' then
makeRow('[[IPA Number]]', ipaNum)
end
if xSampa and xSampa ~= 'hide' then
makeRow('[[X-SAMPA]]', '<code>' .. xSampa .. '
') end if tipa and tipa ~= 'hide' then makeRow('TIPA', '' .. tipa .. '
') end if praat and praat ~= 'hide' then makeRow('Praat', '' .. praat .. '
') end if keyman and keyman ~= 'hide' then makeRow('Keyman', '' .. keyman .. '') end if braille and braille[1] ~= 'hide' then braille.type = 6 braille.size = '25px' braille = mw.getCurrentFrame:expandTemplate makeRow('IPA Braille', braille) end return sendfunction p.encoding(frame) local args = for k, v in pairs(frame.args) do args[k] = v ~= and v end if not args[1] then return end return p._encoding(args[1], args.ipa_number, args.xsampa, args.tipa, args.praat, args.braille)end
return p