Module:IPA: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 5: Line 5:
nolarge = {type = "boolean"},
nolarge = {type = "boolean"},
linked = {type = "boolean"},
linked = {type = "boolean"},
nopre = {alias = "noprefix"},
nopre = {type = "boolean"},
noprefix = {type = "boolean"},
}
}


Line 17: Line 16:
local language_pron = "Appendix:" .. language.name .. "_pronunciation"
local language_pron = "Appendix:" .. language.name .. "_pronunciation"
out = ""
out = ""
if not args["noprefix"] then
if not args["nopre"] then
out = out .. "[[w:International_Phonetic_Alphabet|IPA]]"
out = out .. "[[w:International_Phonetic_Alphabet|IPA]]"
out = out .. "<sup>([[" .. language_pron .. "|key]])</sup>:&nbsp;"
out = out .. "<sup>([[" .. language_pron .. "|key]])</sup>:&nbsp;"

Revision as of 16:21, 9 February 2024

{{IPA}}


local export = {}
local params = {
	[1] = {},
	[2] = {list = true},
	nolarge = {type = "boolean"},
	linked = {type = "boolean"},
	nopre = {type = "boolean"},
}

function export.show(frame)
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local language = require("Module:languages").get_by_code(args[1])
	if language == nil then
		error("No such language: " .. args[1])
	end
	local language_pron = "Appendix:" .. language.name .. "_pronunciation"
	out = ""
	if not args["nopre"] then
		out = out .. "[[w:International_Phonetic_Alphabet|IPA]]"
		out = out .. "<sup>([[" .. language_pron .. "|key]])</sup>:&nbsp;"
	end
	local class = "IPA"
	if args["nolarge"] then class = class .. " nolarge" end
	for i, i_ipa in ipairs(args[2]) do
		if i > 1 then out = out .. ", " end
		out = out .. '<span class="' .. class .. '">'
		if args["linked"] then
			out = out .. "[[" .. language_pron .. "|" .. i_ipa .. "]]"
		else
			out = out .. i_ipa
		end
		out = out .. "</span>"
	end
	return out
end

return export