local data = mw.loadData('Module:Sandbox/Nardog/8t').datalocal p =
local find = mw.ustring.findlocal gsub = mw.ustring.gsublocal sub = mw.ustring.sublocal trim = mw.text.trim
local function reverseLook(t, s) local ret for i = 1, #s - 1 do ret = t[sub(s, i, 2)] -- Look for 2-char matches first if ret then return ret end ret = t[sub(s, i, 1)] if ret then return ret end end ret = t[sub(s, -1)] -- Last character if ret then return ret endend
local function returnData(s, dataType) for _, v in ipairs(data.univPatterns) do s = gsub(s, v.pat, v.rep) end local key = s for _, v in ipairs(data.keyPatterns) do key = gsub(key, v.pat, v.rep) end local ret = data.sounds[key] or data.diacritics[key] or reverseLook(data.diacritics, s) if ret and dataType then if ret[dataType] then ret = ret[dataType] else error(string.format('Invalid data type "%s"', dataType)) end end return retend
local function returnErrorCat local ns = mw.title.getCurrentTitle.namespace if ns % 2
local function returnError(s) return string.format('
Error using : "%s" not found in list%s', s, returnErrorCat)endfunction p._main(s, errorText, output) return returnData(s, output or 'article') or errorText or returnError(s)end
function p.main(frame) local args = for k, v in pairs(frame.args) do args[k] = v ~= and v end if not args.symbol then return end -- Exit early if args.errortext
function p._link(s, displayText, prefix, suffix, audio, errorText) local t = returnData(s) if t then local span = mw.html.create('span'):addClass('IPA') if prefix or suffix then span:addClass('nowrap'):attr('title', 'Representation in the International Phonetic Alphabet (IPA)') end span:wikitext(string.format('%s%s%s', prefix or , t.article, displayText or s, suffix or )) if audio then audio = require('Module:Yesno')(audio, audio) if audio
function p.link(frame) local args = for k, v in pairs(frame.args) do args[k] = v ~= and v end if not args.symbol then return end -- Exit early if args.errortext
return p