Module:Sind-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:Sind-translit/documentation. [edit]
- Useful links: subpage list β’ links β’ transclusions β’ testcases β’ sandbox
This module will transliterate text in the Khudawadi script. It is used to transliterate Kachchi and Sindhi.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}
.
Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:Sind-translit/testcases.
Functions
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
local consonants = {
['πΊ']='k', ['π»']='kh', ['πΌ']='g', ['π½']='gΜ', ['πΎ']='gh', ['πΏ']='αΉ
',
['π']='c', ['π']='ch', ['π']='j', ['π']='jΜ', ['π']='jh', ['π
']='Γ±',
['π']='αΉ', ['π']='αΉh', ['π']='αΈ', ['π']='dΜ€', ['π']='αΉ',['π']='αΈh', ['π']='αΉ',
['π']='t', ['π']='th', ['π']='d', ['π']='dh', ['π']='n',
['π']='p', ['π']='ph', ['π']='b', ['π']='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