E Victionario
Jump to navigation Jump to search


This module will transliterate text in “Servocroate language”.

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:sh-translit/testcases.


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

local export = {}
local tt = {
	["А"]='A', ["а"]='a', ["Б"]='B', ["б"]='b', ["В"]='V', ["в"]='v', ["Г"]='G', ["г"]='g', ["Д"]='D', ["д"]='d', 
	["Ђ"]='Đ', ["ђ"]='đ', ["Е"]='E', ["е"]='e', ["Ж"]='Ž', ["ж"]='ž', ["З"]='Z', ["з"]='z', ["И"]='I', ["и"]='i', 
	["Ј"]='J', ["ј"]='j', ["К"]='K', ["к"]='k', ["Л"]='L', ["л"]='l', ["Љ"]='Lj', ["љ"]='lj', ["М"]='M', ["м"]='m', 
	["Н"]='N', ["н"]='n', ["Њ"]='Nj', ["њ"]='nj', ["О"]='O', ["о"]='o', ["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r', 
	["С"]='S', ["с"]='s', ["Т"]='T', ["т"]='t', ["Ћ"]='Ć', ["ћ"]='ć', ["У"]='U', ["у"]='u', ["Ф"]='F', ["ф"]='f', 
	["Х"]='H', ["х"]='h', ["Ц"]='C', ["ц"]='c', ["Ч"]='Č', ["ч"]='č', ["Џ"]='Dž', ["џ"]='dž', ["Ш"]='Š', ["ш"]='š', 
	-- letters with diacritics
	["ѐ"]='è', ["Ѐ"]='È', ["ѝ"]='ì', ["Ѝ"]='Ì', ["ӣ"]='ī', ["Ӣ"]='Ī', ["ӯ"]='ū', ["Ӯ"]='Ū',
	["а́"]='á', ["А́"]='Á', ["а̀"]='à', ["А̀"]='À', ["а̄"]='ā', ["А̄"]='Ā', ["а̏"]='ȁ', ["А̏"]='Ȁ', 
	["а̑"]='ȃ', ["А̑"]='Ȃ', ["е́"]='é', ["Е́"]='É', ["е̄"]='ē', ["Е̄"]='Ē', ["е̏"]='ȅ', ["Е̏"]='Ȅ', 
	["е̑"]='ȇ', ["Е̑"]='Ȇ', ["и́"]='í', ["И́"]='Í', ["и̏"]='ȉ', ["И̏"]='Ȉ', ["и̑"]='ȋ', ["И̑"]='Ȋ', 
	["о́"]='ó', ["О́"]='Ó', ["о̀"]='ò', ["О̀"]='Ò', ["о̄"]='ō', ["О̄"]='Ō', ["о̏"]='ȍ', ["О̏"]='Ȍ', 
	["о̑"]='ȏ', ["О̑"]='Ȏ', ["р́"]='ŕ', ["Р́"]='Ŕ', ["р̀"]='r̀', ["Р̀"]='R̀', ["р̄"]='r̄', ["Р̄"]='R̄', 
	["р̏"]='ȑ', ["Р̏"]='Ȑ', ["р̑"]='ȓ', ["Р̑"]='Ȓ', ["у́"]='ú', ["У́"]='Ú', ["у̀"]='ù', ["У̀"]='Ù', 
	["у̏"]='ȕ', ["У̏"]='Ȕ', ["у̑"]='ȗ', ["У̑"]='Ȗ', 
	-- proposed Montenegrin letters
	["З́"]='Ź', ["з́"]='ź', ["Ć"]='Ś', ["ć"]='ś'

-- TODO: Can we make this transliterate Latn to Cyrl as well?
function, lang, sc)
    return (mw.ustring.gsub(f, '.', tt))

return export