Module:User:OblivionKhorasan/skr-IPA-translit
Appearance
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
Language code in page name (User:OblivionKhorasan/skr
) not recognized.
local m_str_utils = require("Module:string utilities")
local U = m_str_utils.char
local gsub = m_str_utils.gsub
local export = {}
local nasal = 'J'
local nasalised = '̃'
local nasalc = "mnɳɲŋ"
local aspirate = "ʰʱ"
local unvoiced = "ptʈçk"
local stress = "ˈˌ"
local consonants = "pbɓtdɗʈɖᶑɽçɟʄkɡɠɾlɭsɦʃʋqxɣzfmnɳɲŋj"
local schwac = "pbɓtdɗʈɖᶑɽçɟʄkɡɠɾlɭsʃqzfʰʱmnɳɲŋ"
local gem = "pbɓtdɗʈɖᶑçɟʄkɡɠlsʃqxɣzfʰʱmnɲŋ"
local ungem = "ɳɭɾɽjʋɦ"
local vowels = "əɪʊaiueoɛɔ"
local shortvowels = "əɪʊ"
local longvowels = "aiueoɛɔ"
local long = "ː"
local nonsyllabic = '̯'
local labial = "pbɓf"
local dental = "tdɗ"
local retroflex = "ʈɖᶑ"
local postalveolar = "çɟʄ"
local velar = "kɡɠ"
local postvelar = "xɣ"
local sibilant = "sʃɦ"
local mapping = {
["T"] = 'ʈ', ["D"] = 'ɖ', ["N"] = 'ɳ',
["R"] = "ɽ",
["c"] = 'ç', ["j"] = 'ɟ', ["ñ"] = 'ɲ',
["g"] = 'ɡ',
["y"] = 'j', ["r"] = 'ɾ', ["L"] = 'ɭ', ["v"] = 'ʋ',
["h"] = "ɦ",
["ś"] = "ʃ", ["ġ"] = "ɣ",
["a"] = 'ə', ["i"] = 'ɪ', ["u"] = 'ʊ',
["ā"] = 'a', ["ī"] = 'i', ["ū"] = 'u', ["ē"] = 'ɛ', ["ō"] = 'ɔ',
["ṉ"] = "J",
["`"] = 'ˈ',
[","] = 'ˌ',
["H"] = 'ʱ',
}
function export.tr(text, lang, sc)
--define the "end" of a word
text = gsub(text, "#", "HASHTAG")
text = gsub(text, " | ", "# | #")
text = gsub(text, "\n" , "#".."\n" .. "#")
text = "##" .. gsub(text, " ", "# #") .. "##"
-- hastags now mark the beginning and end of a word
text = gsub(text, '.', mapping)
-- implosives
text = gsub(text, "b'", "ɓ")
text = gsub(text, "d'", "ɗ")
text = gsub(text, "ɖ'", "ᶑ")
text = gsub(text, "ɟ'", "ʄ")
text = gsub(text, "ɡ'", "ɠ")
-- unvoiced aspirates
text = gsub(text, '([' .. unvoiced .. '])' .. '([' .. aspirate .. '])', "%1ʰ")
-- nasalise vowels
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasalc .. '])' .. '([' .. consonants .. '])', "%1̃%2%3")
text = gsub(text, '([' .. stress .. '])' .. '([' .. vowels .. long .. '])' .. '([' .. nasalc .. '])', "%1%2̃%3")
text = gsub(text, '([' .. stress .. '])' .. '([' .. consonants .. '])' .. '([' .. vowels .. long .. '])' .. '([' .. nasalc .. '])', "%1%2%3̃%4")
text = gsub(text, "#" .. '([' .. consonants .. aspirate .. '])' .. '([' .. vowels .. '])' .. '([' .. nasalc .. '])' .. "#", "%1%2̃.%3")
-- nasal consonant combinations
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. labial .. '])', "%1̃m%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. dental .. '])', "%1̃n%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. retroflex .. '])', "%1̃ɳ%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. postalveolar .. '])', "%1̃n̠%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. velar .. '])', "%1̃ŋ%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. postvelar .. '])', "%1̃ŋ̄%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. sibilant .. '])', "%1̃%3")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. "#", "%1̃")
-- stressed variants (not sure how to condense)
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. labial .. '])', "%1̃m%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. dental .. '])', "%1̃n%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. retroflex .. '])', "%1̃ɳ%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. postalveolar .. '])', "%1̃n̠%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. velar .. '])', "%1̃ŋ%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. postvelar .. '])', "%1̃ŋ̄%3%4")
text = gsub(text, '([' .. vowels .. '])' .. '([' .. nasal .. '])' .. '([' .. stress .. '])' .. '([' .. sibilant .. '])', "%1̃%3%4")
-- vowel lengthening
text = gsub(text, '([' .. longvowels .. '])' .. '([' .. ungem .. '])', "%1ː%2")
text = gsub(text, '([' .. longvowels .. '])' .. '([' .. nasalised .. '])' .. '([' .. ungem .. '])', "%1%2ː%3")
text = gsub(text, '([' .. longvowels .. nasalised .. '])' .. "#", "%1ː")
text = gsub(text, '([' .. longvowels .. nasalised .. '])' .. '([' .. consonants .. aspirate .. '])' .. "#", "%1ː%2")
text = gsub(text, '([' .. stress .. consonants .. aspirate .. '])' .. '([' .. longvowels .. '])' .. '([' .. consonants .. aspirate .. '])', "%1%2ː%3")
text = gsub(text, '([' .. stress .. consonants .. aspirate .. '])' .. '([' .. longvowels .. '])' .. '([' .. nasalised .. '])' .. '([' .. consonants .. aspirate .. '])', "%1%2%3ː%4")
-- consonant doubling after stressed long vowels
text = gsub(text, '([' .. stress .. consonants .. aspirate .. '])' .. '([' .. longvowels .. '])' .. '([' .. long .. '])' .. '([' .. gem .. '])' .. '([' .. vowels .. '])', "%1%2%3%4%4%5")
text = gsub(text, '([' .. stress .. consonants .. aspirate .. '])' .. '([' .. longvowels .. '])' .. '([' .. long .. '])' .. '([' .. gem .. '])' .. '([' .. aspirate .. '])' .. '([' .. vowels .. '])', "%1%2%3%4%4%5%6")
-- iy cluster
text = gsub(text, "ɪj", "i.j")
text = gsub(text, "ɪ" .. '([' .. stress .. '])' .. "j", "i%1j")
text = gsub(text, "jj", "i̯.j")
-- schwa release
text = gsub(text, '([' .. schwac .. '])' .. "#", "%1ə̆")
-- syllables
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. consonants .. '])' .. '([' .. consonants .. '])' .. '([' .. vowels .. '])', "%1%2.%3%4") -- separates consonants
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. consonants .. '])' .. '([' .. consonants .. '])' .. '([' .. aspirate .. '])' .. '([' .. vowels .. '])', "%1%2.%3%4%5")
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. consonants .. '])' .. '([' .. vowels .. '])', "%1.%2%3") -- separates C-V
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. stress .. '])', "%1.%2")
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. consonants .. '])' .. '([' .. stress .. '])', "%1%2.%3")
text = gsub(text, '([' .. vowels .. nasalised .. long .. '])' .. '([' .. vowels .. '])', "%1.%2") -- separates vowel clusters
text = gsub(text, "." .. '([' .. vowels .. nasalised .. long .. '])' .. '([' .. nonsyllabic .. '])', "%1%2") -- nonsyllabic vowel clusters
-- repairing n̠
text = gsub(text, '([' .. "n̠" .. '])' .. '([' .. consonants .. stress .. '])', "%1.%2")
-- ñ fix
text = gsub(text, '([' .. nasalised .. long ..'])' .. '([' .. "." .. '])' .. '([' .. "ɲ" .. '])', "%1%3%2%3")
-- manual fix
text = gsub(text, '([' .. shortvowels .. '])' .. '([' .. nasalised .. '])' .. '([' .. long .. '])', "%1%2")
text = gsub(text, '([' .. shortvowels .. '])' .. '([' .. consonants .. '])' .. '([' .. vowels .. '])', "%1.%2%3")
-- get rid of hashtags (not needed)
text = gsub(text, "#", "")
text = gsub(text, "HASHTAG", "#")
--
return text
end
return export