This module will transliterate text in the Khudabadi 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.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.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 = {
h?"] = "ṅ",
h?"] = "ñ",
h?"] = "ṇ",
h?"] = "n",
h?"] = "m",
= "n",
= "m",
= "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 or c
if d == "" then
return c .. 'a'
else
return c .. (diacritics 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,"()ṁ ", "%1̃ ")
text = mw.ustring.gsub(text,"(.?)ṁ", "%1̃")
text = mw.ustring.gsub(text, 'a()̃', 'a͠%1')
return mw.ustring.toNFC(text)
end
return export