Module:Sidd-translit
Jump to navigation
Jump to search
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list โข links โข transclusions โข testcases โข sandbox
This module will transliterate text in the Siddham script. It is used to transliterate Apabhramsa, Kamarupi Prakrit, and Sanskrit.
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:Sidd-translit/testcases.
Functions
[edit]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 m_str_utils = require("Module:string utilities")
local gsub = m_str_utils.gsub
local match = m_str_utils.match
local toNFC = mw.ustring.toNFC
local u = m_str_utils.char
local consonants = {
['๐']='k', ['๐']='kh', ['๐']='g', ['๐']='gh', ['๐']='แน
',
['๐']='c', ['๐']='ch', ['๐']='j', ['๐']='jh', ['๐']='รฑ',
['๐']='แนญ', ['๐']='แนญh', ['๐']='แธ', ['๐']='แธh', ['๐']='แน',
['๐']='t', ['๐']='th', ['๐']='d', ['๐ ']='dh', ['๐ก']='n',
['๐ข']='p', ['๐ฃ']='ph', ['๐ค']='b', ['๐ฅ']='bh', ['๐ฆ']='m',
['๐ง']='y', ['๐จ']='r', ['๐ฉ']='l', ['๐ช']='v',
['๐ซ']='ล', ['๐ฌ']='แนฃ', ['๐ญ']='s', ['๐ฎ']='h',
}
local diacritics = {
['๐ฏ']='ฤ', ['๐ฐ']='i', ['๐ฑ']='ฤซ', ['๐ฒ']='u', ['๐ณ']='ลซ', ['๐ด']='แน', ['๐ต']='แน',
['๐ธ']='e', ['๐น']='ai', ['๐บ']='o', ['๐ป']='au', ['๐ฟ']='',
-- For Japanese Siddham, these alternate vowel signs are the 'warbler' forms while the regular vowel signs are the 'cloud' forms.
['๐'] = '', -- Alternate Vowel Sign U
['๐'] = '', -- Alternate Vowel Sign UU
}
local diatrema = {
['๐']='รฏ', ['๐']='รผ',
}
local tt = {
-- vowels
['๐']='a', ['๐']='ฤ', ['๐']='i', ['๐']='ฤซ', ['๐']='u', ['๐
']='ลซ', ['๐']='แน', ['๐']='แน',
['๐']='แธท', ['๐']='แธน', ['๐']='e', ['๐']='ai', ['๐']='o', ['๐']='au',
-- chandrabindu
['๐ผ']='mฬ', --until a better method is found
-- anusvara
['๐ฝ']='แน', --until a better method is found
-- visarga
['๐พ']='แธฅ',
--numerals
--punctuation
['๐']='.', --double danda
['๐']='.', --danda
--reconstructed
['*'] = '',
}
function export.tr(text, lang, sc)
text = gsub(
text,
'([๐-๐ฎ])'..
'([๐ฏ-๐ต๐ธ-๐ป๐ฟ๐๐]?)'..
'([๐๐]?)',
function(c, d, e)
if d == "" and e ~= "" then
return consonants[c] .. 'a' .. diatrema[e]
elseif e ~= "" then
return consonants[c] .. diacritics[d] .. tt[e]
elseif d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. diacritics[d]
end
end)
-- Adjacent vowel letters needing dieresis
text = gsub(text, '([๐])([๐๐])', function(a, b) return tt[a]..diatrema[b] end)
text = gsub(text, '.', tt)
return text
end
return export