Module:Sind-translit
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Sind-translit/doc
local export = {}
local consonants = {
['πΊ']='k', ['π»']='kh', ['πΌ']='g', ['π½']='gΜ ', ['πΎ']='gh', ['πΏ']='αΉ
',
['π']='c', ['π']='ch', ['π']='j', ['π']='jΜ', ['π']='jh', ['π
']='Γ±',
['π']='αΉ', ['π']='αΉh', ['π']='αΈ', ['π']='αΈΜ ', ['π']='αΉ',['π']='αΈh', ['π']='αΉ',
['π']='t', ['π']='th', ['π']='d', ['π']='dh', ['π']='n',
['π']='p', ['π']='ph', ['π']='b', ['π']='αΈ', ['π']='bh', ['π']='m',
['π']='y', ['π']='r', ['π']='l', ['π']='v', ['π']='Ε',
['π']='s', ['π']='h',
--consonants with nukta
["πΊπ©"] = "q",
["π»π©"] = "x",
["πΌπ©"] = "Δ‘",
["ππ©"] = "z",
["ππ©"] = "αΉh",
["ππ©"] = "f",
}
local diacritics = {
['π ']= 'Δ', ['π‘']='i', ['π’']='Δ«', ['π£']='u', ['π€']='Ε«',
['π₯']='e', ['π¦']='ai', ['π§']='o', ['π¨']='au', ['πͺ']='',
}
local nonconsonants = {
-- vowels
['π°']='a', ['π±']='Δ', ['π²']='i', ['π³']='Δ«', ['π΄']='u', ['π΅']='Ε«',
['πΆ']='e', ['π·']='ai', ['πΈ']='o',['πΉ']='au',
-- other symbols
['π']='αΉ', -- anusvara
['π©']='.', -- nukta
-- digits
['π°'] = '0', ['π±'] = '1', ['π²'] = '2', ['π³'] = '3', ['π΄'] = '4',
['π΅'] = '5', ['πΆ'] = '6', ['π·'] = '7', ['πΈ'] = '8', ['πΉ'] = '9',
}
local nasal_assim = {
["[kg]h?"] = "αΉ
",
["[cj]h?"] = "Γ±",
["[αΉαΈ]h?"] = "αΉ",
["[td]h?"] = "n",
["[pb]h?"] = "m",
["n"] = "n",
["m"] = "m",
["s"] = "n",
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local nukta = "([π»πΌππ]π©)"
text = mw.ustring.gsub(
text,
'([πΊπ»πΌπ½πΎπΏππππππ
πππππππππππππππππππππππππ][π©]?)'..
'([π π‘π’π£π€π₯π¦π§π¨πͺ]?)',
function(c, d)
-- mw.log('match', c, d)
c = consonants[c] or c
if d == "" then
return c .. 'a'
else
return c .. (diacritics[d] or d)
end
end)
text = mw.ustring.gsub(text,nukta,consonants)
text = mw.ustring.gsub(text, '.', nonconsonants)
for key,val in pairs(nasal_assim) do
text = mw.ustring.gsub(text,"αΉ("..key..")",val.."%1")
end
text = mw.ustring.gsub(text,"([aiueΔoΔΔ«Ε«])αΉ ", "%1Μ ")
text = mw.ustring.gsub(text,"(.?)αΉ", "%1Μ")
text = mw.ustring.gsub(text, 'a([iu])Μ', 'aΝ %1')
return mw.ustring.toNFC(text)
end
return export