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
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
local export = {}
local export = {}


local consonants = {
local tt = {}
['क']='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',
['ू']='ū',
["ॆ"]='ei',
['े']='ēi',
["ॅ"]='e',
['ै']='ē',
['ो']='ōu',
['ौ']='ō',
['्']='',
['॔']='́',
['॓']='̀',


-- from Latin to Devanagari
tt = {
    -- Short vowels
    { "ॅ", "e" },
    { "ॆ", "ei" },
    { "ि", "i" },
    { "ॉ", "o" },
    { "ॊ", "ou" },
    { "ु", "u"},
   
    { "अ", "a" },
    { "ऍ", "e" },
    { "ऎ", "ei" },
    { "इ", "i" },
    { "ऑ", "o" },
    { "ऒ", "ou" },
    { "उ", "u"},
}
}


local tt = {
function export.tr(text, lang, sc)
-- vowels
text = mw.ustring.lower(text)
['अ']='a',
['आ']='ā',
['इ']='i',
['ई']='ī',
['उ']='u',
['ऊ']='ū',
['ऎ']="ei",
['ए']='ēi',
['ऍ']='e',
['ऐ']='ē',
['ऒ']='ou',
['ओ']='ōu',
['ऑ']='o',
['औ']='ō',
['ं']='̣', --until a better method is found
['ः']='ḥ',
['०']='0', ['१']='1', ['२']='2', ['३']='3', ['४']='4', ['५']='5', ['६']='6', ['७']='7', ['८']='8', ['९']='9',
}
function export.tr(text, lang, sc)
for _, rule in ipairs(tt) do
if sc ~= "Deva" then
text = mw.ustring.gsub(text, rule[1], rule[2])
return nil
end
end
    return text
end
end


return export
return export

Latest revision as of 23:51, 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.

local export = {}

local tt = {}

-- from Latin to Devanagari
tt = {
    -- Short vowels
    { "ॅ", "e" },
    { "ॆ", "ei" },
    { "ि", "i" },
    { "ॉ", "o" },
    { "ॊ", "ou" },
    { "ु", "u"},
    
    { "अ", "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