Module:Sind-translit
Appearance
- 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 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.
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', ['𑋈']='ḍ', ['𑋉']='ḍ̠', ['𑋊']='ṛ',['𑋋']='ḍ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