local export = {}
local lang = require("Module:languages").getByCode("ta")
local sc = require("Module:scripts").getByCode("Taml")
local m_IPA = require("Module:IPA")
local gsub = mw.ustring.gsub
local gmatch = mw.ustring.gmatch
local find = mw.ustring.find
local u = mw.ustring.char
local correspondences = {
= "ŋ", = "ɡ", = "k",
= "ɳ", = "ɖ", = "ʈ",
= "n", = "n̪", = "d̪", = "t̪",
= "m", = "b", = "p",
= "ɲ", = "t͡ʃ",
= "r", = "ɻ", = "ʋ", = "ɾ̪",
= "ʂ", = "d͡ʒ", = "ʃ",
= "h", = "x",
= "m", = "j",
= "a", = "e", = "i", = "o", = "u",
= "aː", = "eː", = "iː", = "oː", = "uː",
}
local vowels = "aeiou"
local voiced_cons = "tkṭpc"
local voicing = {
= "d", = "g", = "ḍ", = "b", = "j",
}
local nasals = "nṇñṅṉm"
local function transliterate(text)
return lang:transliterate(text)
end
function export.link(term)
return require("Module:links").full_link{ term = term, lang = lang, sc = sc }
end
function export.toIPA(text)
local translit = transliterate(text)
if not translit then
error('The term could not be transliterated.')
end
-- VOICED AFTER NASAL
translit = gsub(translit, "()()", function(a,b) return a .. voicing end)
translit = gsub(translit, "()()", function(a,b) return a .. voicing end)
translit = gsub(translit, "()()", function(a,b) return a .. voicing end)
translit = gsub(translit, "()()", function(a,b) return a .. voicing end)
translit = gsub(translit, "()()", function(a,b) return a .. voicing end)
-- VOICING
translit = gsub(translit, "()()()", function(a,b,c)
return a .. voicing .. c end)
-- ற் gemination and ன்ற
translit = gsub(translit, "", "ṭṭr")
translit = gsub(translit, "", "ṇḍr")
-- VOICELESS GEMINATION
translit = gsub(translit, "(k)", "%1ː")
translit = gsub(translit, "(t)", "%1ː")
translit = gsub(translit, "(c)", "%1ː")
translit = gsub(translit, "(ṭ)", "%1ː")
translit = gsub(translit, "(p)", "%1ː")
local result = gsub(translit, ".", correspondences)
return result
end
function export.make(frame)
local args = frame:getParent().args
local pagetitle = mw.title.getCurrentTitle().text
local p, results = {}, {}, {}
if args then
for index, item in ipairs(args) do
table.insert(p, (item ~= "") and item or nil)
end
else
p = { pagetitle }
end
for _, Tamil in ipairs(p) do
table.insert(results, { pron = "/" .. export.toIPA(Tamil) .. "/" })
end
return m_IPA.format_IPA_full { lang = lang, items = results }
end
return export