Module:IPA: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
Tag: Manual revert
No edit summary
Line 6: Line 6:
linked = {type = "boolean"},
linked = {type = "boolean"},
nopre = {type = "boolean"},
nopre = {type = "boolean"},
}
local params_inline = {
[1] = {},
[2] = {list = true},
}
}


function export.show(frame)
function format_ipa(language, ipa, nolarge, nopre, linked)
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"
local language_pron = "Appendix:" .. language.name .. "_pronunciation"
out = ""
local out = ""
if not args["nopre"] then
if not 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;"
end
end
local class = "IPA"
local class = "IPA"
if args["nolarge"] then class = class .. " nolarge" end
if nolarge then class = class .. " nolarge" end
for i, i_ipa in ipairs(args[2]) do
for i, i_ipa in ipairs(ipa) do
if i > 1 then out = out .. ", " end
if i > 1 then out = out .. ", " end
out = out .. '<span class="' .. class .. '">'
out = out .. '<span class="' .. class .. '">'
if args["linked"] then
if linked then
out = out .. "[[" .. language_pron .. "|" .. i_ipa .. "]]"
out = out .. "[[" .. language_pron .. "|" .. i_ipa .. "]]"
else
else
Line 33: Line 32:
end
end
return out
return out
end
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
return format_ipa(args[1], args[2], args["nolarge"], args["nopre"], args["linked"])
end
function export.show_inline(frame)
local args = require("Module:parameters").process(frame:getParent().args, params_inline)
local language = require("Module:languages").get_by_code(args[1])
if language == nil then
error("No such language: " .. args[1])
end
return format_ipa(args[1], args[2], true, true, true)
end
end


return export
return export

Navigation menu