Module:User:Rua/pronunciation

local export = {}

local columns = { {code = "variety", display = "variety"}, {code = "IPA", display = "IPA"}, {code = "audio", display = "Audio"}, {code = "homophones", display = "Homophones"}, {code = "hyphenation", display = "Hyphenation"}, }

local lang = require("Module:languages").getLanguageByCode("nl")

function export.show(frame) local data = { {variety = "NL", IPA = "/ˈrɛizə(n)/", audio = "nl-reizen.ogg", hyphenation = "rei-zen", homophones = "rijzen"}, {variety = "BE", IPA = "/ˈrɛːzə(n)/", hyphenation = "rei-zen", homophones = "rijzen"}, }	-- Determine which columns need to be displayed local found_columns = {} for _, row in ipairs(data) do		for code, _ in pairs(row) do			found_columns[code] = true end end -- Format table for key, row in ipairs(data) do		for _, col in ipairs(columns) do			if found_columns[col.code] then table.insert(row, process_value(col.code, row[col.code])) end end data[key] = " " .. table.concat(row, " ") .. " "	end local head_row = {} for _, col in ipairs(columns) do		if found_columns[col.code] then table.insert(head_row, col.display) end end head_row = " " .. table.concat(head_row, " ") .. " "	return " " end

function process_value(code, val) if not val then return "" elseif code == "variety" then local template = mw.title.new("Template:accent:" .. val) if template.exists then return mw.getCurrentFrame:expandTemplate{title = "Template:accent:" .. val, args = {}} else return val end elseif code == "IPA" then return mw.getCurrentFrame:expandTemplate{title = "IPAchar", args = {val}} elseif code == "audio" then return mw.getCurrentFrame:expandTemplate{title = "audio", args = {val, lang = lang:getCode}} elseif code == "homophones" then return require("Module:links").full_link(val, nil, lang, nil, nil, nil, nil, nil) elseif code == "hyphenation" then return (val:gsub("-", "‧", nil)) else return val end end

return export