Module:IPA
Appearance
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
![]() | This Lua module is used on approximately 164,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
See Template:IPA.
local gsub = mw.ustring.gsub
local U = mw.ustring.char
local p = {}
local function IPAspan(text)
return '<span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA">'..text..'</span>'
end
function p.IPA(frame)
local args = frame:getParent().args[1] and frame:getParent().args or frame.args
local namespace = mw.title.getCurrentTitle().nsText
local languageCode = args[2] and args[1] or nil
local IPApages = require("Module:IPA/data")
local text = (languageCode and args[2]) or args[1] or ( (namespace == "Template" or namespace == "Module") and "[ɪɡˈzɑːmpəl]")
text = gsub(text, U(0x67), U(0x261)) -- Replace regular g with IPA g.
local IPApage = languageCode and IPApages[languageCode] or nil
local out = text and ( (IPApage and IPAspan("[["..IPApage.."|"..text.."]]") ) or IPAspan(text)) or '<sup>[IPA symbols?]</sup>'
return out
end
return p