Module:tevo-translit: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Melinoë (talk | contribs)
No edit summary
Melinoë (talk | contribs)
No edit summary
Line 1: Line 1:
local export = {}
-- from Latin to Devanagari
 
tt = {
local consonants = {
    -- Short vowels
['क']='k', ['ख']='kh', ['ग']='g', ['घ']='gh', ['ङ']='ṅ',
    { "a", "" },  
['च']='c', ['छ']='ch', ['ज']='j', ['झ']='jh', ['ञ']='ñ',  
    { "e", "ॅ" },
['ट']='ṭ', ['ठ']='ṭh', ['ड']='ḍ', ['ढ']='ḍh', ['ण']='ṇ',
    { "ei", "ॆ" },
['त']='t', ['थ']='th', ['द']='d', ['ध']='dh', ['न']='n',  
    { "i", "ि" },
['प']='p', ['फ']='ph', ['ब']='b', ['भ']='bh', ['म']='m',
    { "o", "ॉ" },
['य']='y', ['र']='r', ['ल']='l', ['व']='v', ['ळ']='ḷ',
    { "ou", "" },
['श']='ś', ['ष']='ṣ', ['स']='s', ['ह']='h',
    { "u", ""},
}
 
local diacritics = {
['ा']='ā',  
['ि']='i',  
['ी']='ī',  
['ु']='u',
['ू']='ū',
[""]='ei',
['े']='ēi',
[""]='e',
['ै']='ē',
['ो']='ōu',
['ौ']='ō',
['्']='',
['॔']='́',
['॓']='́',
['ं']='̣', --until a better method is found
 
}
}


local tt = {
-- vowels
['अ']='a',
['आ']='ā',
['इ']='i',
['ई']='ī',
['उ']='u',
['ऊ']='ū',
['ऎ']="ei",
['ए']='ēi',
['ऍ']='e',
['ऐ']='ē',
['ऒ']='ou',
['ओ']='ōu',
['ऑ']='o',
['औ']='ō',
['ः']='ḥ',
['०']='0', ['१']='1', ['२']='2', ['३']='3', ['४']='4', ['५']='5', ['६']='6', ['७']='7', ['८']='8', ['९']='9',
}
function export.tr(text, lang, sc)
function export.tr(text, lang, sc)
text = mw.ustring.lower(text)
text = mw.ustring.lower(text)

Revision as of 23:45, 29 May 2026


This module will transliterate Ancient Tevvic language text. It is also used to transliterate Middle Tevvic and Tevvic. 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:tevo-translit/testcases.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

-- from Latin to Devanagari
tt = {
    -- Short vowels
    { "a", "" }, 
    { "e", "ॅ" },
    { "ei", "ॆ" },
    { "i", "ि" },
    { "o", "ॉ" },
    { "ou", "ॊ" },
    { "u", "ु"},
}

function export.tr(text, lang, sc)
	text = mw.ustring.lower(text)
	
	for _, rule in ipairs(tt) do
		text = mw.ustring.gsub(text, rule[1], rule[2])
	end

    return text
end

return export