Module:User:Bababashqort:ky-translit
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: subpage list • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Bababashqort:ky-translit, for their own experimentation. Items in this module may be added and removed at Bababashqort:ky-translit's discretion; do not rely on this module's stability.
local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("ky")
local C = "[бвгджзйклмнңпрстфхцчшщ]" -- consonants
local bV = "[аыоу]"
local fV = "[эиөү]"
local iV = "[еёюя]" -- iotated vowels
local lowerc = {
["А"]="а", ["Б"]="б", ["В"]="в", ["Г"]="г", ["Д"]="д", ["Е"]="е",
["Ё"]="ё", ["Ж"]="ж", ["З"]="з", ["И"]="и", ["Й"]="й", ["К"]="к",
["Л"]="л", ["М"]="м", ["Н"]="н", ["Ң"]="ң", ["О"]="о", ["Ө"]="ө",
["П"]="п", ["Р"]="р", ["С"]="с", ["Т"]="т", ["У"]="у", ["Ү"]="ү",
["Ф"]="ф", ["Х"]="х", ["Ц"]="ц", ["Ч"]="ч", ["Ш"]="ш", ["Щ"]="щ",
["Ъ"]="ъ", ["Ы"]="ы", ["Ь"]="ь", ["Э"]="э", ["Ю"]="ю", ["Я"]="я"
}
local phon = {
["б"]="b", ["г"]="ɡ", ["д"]="d", ["ж"]="d͡ʒ", ["з"]="z", ["й"]="j",
["к"]="k", ["л"]="l̴", ["м"]="m", ["н"]="n", ["ң"]="ŋ", ["п"]="p",
["р"]="r", ["с"]="s", ["т"]="t", ["ч"]="t͡ʃ", ["ш"]="ʂ", ["е"]="e",
["ё"]="jo", ["ю"]="ju", ["я"]="jɑ", ["а"]="ɑ", ["ы"]="ɯ", ["о"]="o",
["у"]="u", ["э"]="e", ["и"]="i", ["ө"]="ø", ["ү"]="y", ["в"]="v",
["ф"]="f", ["х"]="x", ["ц"]="t͡s", ["ч"]="t͡ʃ", ["щ"]="ɕ", ["ь"]="ʲ"
}
local function phonetic(text)
text = mw.ustring.gsub(text, '.', lowerc)
text = mw.ustring.gsub(text, '.', phon)
-- Handle к, г uvularization rules
text = mw.ustring.gsub(text, "k[ɑɯou]", "q%1")
text = mw.ustring.gsub(text, "g[ɑɯou]", "ʁ%1")
text = mw.ustring.gsub(text, "[ɑɯou]k", "%1q")
text = mw.ustring.gsub(text, "[ɑɯou]g", "%1ʁ")
text = mw.ustring.gsub(text, "kq", "q")
text = mw.ustring.gsub(text, "gʁ", "ʁ")
text = mw.ustring.gsub(text, "[ɑɯou]k", "%1q")
text = mw.ustring.gsub(text, "[ɑɯou]g", "%1ʁ")
-- Handle ш rules
text = mw.ustring.gsub(text, "ʂ[eiøy]", "ʃ%1")
text = mw.ustring.gsub(text, "[eiøy]ʂ", "%1ʃ")
text = mw.ustring.gsub(text, "ʂʃ", "ʃ")
text = mw.ustring.gsub(text, "ʃʂ", "ʃ")
-- Handle l rules
text = mw.ustring.gsub(text, "l̴[eiøy]", "l%1")
text = mw.ustring.gsub(text, "[eiøy]l̴", "%1l")
text = mw.ustring.gsub(text, "ll̴", "l̴")
text = mw.ustring.gsub(text, "l̴l", "l̴")
-- Handle long vowels
text = mw.ustring.gsub(text, "[ɑ]ɑ", "ɑː")
text = mw.ustring.gsub(text, "[o]o", "oː")
text = mw.ustring.gsub(text, "[u]u", "uː")
text = mw.ustring.gsub(text, "[e]e", "eː")
text = mw.ustring.gsub(text, "[ø]ø", "øː")
text = mw.ustring.gsub(text, "[y]y", "yː")
return text
end
function export.IPA(frame)
local words = {}
for _, word in ipairs(frame:getParent().args) do
table.insert(words, word)
end
if #words == 0 then
words = {mw.title.getCurrentTitle().text}
end
local IPA_results = {}
for _, word in ipairs(words) do
table.insert(IPA_results, { pron = "/" .. phonetic(word) .. "/" })
end
return m_IPA.format_IPA_full { lang = lang, items = IPA_results }
end
return export