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 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