Module:grk-mar-translit

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module will transliterate Mariupol Greek language text per WT:GRK-MAR TR. 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:grk-mar-translit/testcases.

Functions[edit]

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 tri = {
 	["Τσσ"]="Č", ["Τςς"]="Č", ["Τζζ"]="Dž",
 	["τσσ"]="č", ["τςς"]="č", ["τζζ"]="dž", 
}

local di = {
	["Гк"]="G", ["Дъ"]="Ð", ["Тъ"]="Θ",
	['гк']="g", ["дъ"]='ð', ['тъ']='θ',
	["Μπ"]="Mb", ["Νκ"]="Ng", ["Ντ"]="Nd", ["Σσ"]="Š", ["Σς"]="Š", ["Ζζ"]="Ž",
	["Τσ"]="C", ["Τς"]="C", ["Τζ"]="Dz", 
	["μπ"]="mb", ["νκ"]="ng", ["ντ"]="nd", ["σσ"]="š", ["ςς"]="š", ["ζζ"]="ž",
	["τσ"]="c", ["τς"]="c", ["τζ"]="dz",

}

local tab = {
	["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="H", ["Д"]="D",
	["Е"]="Je", ["Ж"]="Ž", ["З"]="Z", ["И"]="I", ["Й"]="J", ["К"]="K", ["Л"]="L",
	["М"]="M", ["Н"]="N", ["О"]="O", ["П"]="P", ["Р"]="R", ["С"]="S",  
	["Т"]="T", ["У"]="U", ["Ф"]="F", ["Х"]="X", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", 
	["Ы"]="Y", ["Э"]="E", ["Ю"]="Ju", ["Я"]="Ja", ["Ь"]="ʹ",
	['а']='a', ['б']='b', ['в']='v', ['г']='h', ['д']='d',
	['е']='je', ['ж']='ž', ['з']='z', ['и']='i', ['й']='j', ['к']='k', ['л']='l', 
	['м']='m', ['н']='n', ['о']='o', ['п']='p', ['р']='r', ['с']='s', 
	['т']='t', ['у']='u', ['ф']='f', ['х']='x', ['ц']='c', ['ч']='č', ['ш']='š', 
	['ы']='y', ['э']='e', ['ю']='ju', ['я']='ja', ['ь']='ʹ', ['щ']='ś',
	
	
	["Α"]="A", ["Β"]="V", ["Γ"]="H", ["Δ"]="Ð", ["Ε"]="E", ["Ζ"]="Z", ["Θ"]="Θ",
	["Ι"]="I", ["Κ"]="K", ["Λ"]="L", ["Μ"]="M", ["Ν"]="N", ["Ο"]="O", ["Π"]="P",
	["Ρ"]="R", ["Σ"]="S", ["Τ"]="T", ["Υ"]="U", ["Φ"]="F", ["Χ"]="X",
	["α"]="a", ["β"]="v", ["γ"]="h", ["δ"]="ð", ["ε"]="e", ["ζ"]="z", ["θ"]="θ",
	["ι"]="i", ["κ"]="k", ["λ"]="l", ["μ"]="m", ["ν"]="n", ["ο"]="o", ["π"]="p",
	["ρ"]="r", ["σ"]="s", ["ς"]="s", ["τ"]="t", ["υ"]="u", ["φ"]="f", ["χ"]="x",
	
	-- accents
	["Ά"]="Á", ["ά"]="á", ["Έ"]="É", ["έ"]="é", ["Ί"]="Í", ["ί"]="í",
	["Ό"]="Ó", ["ό"]="ó", ["Ύ"]="Ú", ["ύ"]="ú"
}

function export.tr(text, lang, sc)

    text = mw.ustring.gsub(text, "Γι([ΑΕΙΟΥαειου])", "J%1")
    text = mw.ustring.gsub(text, "γι([ΑΕΙΟΥαειου])", "j%1")
   	text = mw.ustring.gsub(text, '...',tri)
   	text = mw.ustring.gsub('Q' .. text, '...',tri)
   	text = mw.ustring.gsub('Q' .. text, '...',tri)
   	text = mw.ustring.gsub('Q' .. text, '...',tri)
   	    text = mw.ustring.gsub(text, 'Q', '')
    text = mw.ustring.gsub(text, '..',di)
    text = mw.ustring.gsub('Q' .. text, '..',di)
    text = mw.ustring.gsub('Q' .. text, '..',di)
        text = mw.ustring.gsub(text, 'Q', '')
    text = mw.ustring.gsub(text, '.',tab)
        
    return (text)
end

return export