Module:dlg-translit

From Wiktionary, the free dictionary
Jump to navigation Jump to search
A user suggests that this Dolgan module page be cleaned up.
Please see the discussion on Requests for cleanup(+) for more information and remove this template after the problem has been dealt with.

This module will transliterate Dolgan language text per WT:DLG 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:dlg-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 tab = {
	["А"]='A', ["а"]='a', ["Б"]='B', ["б"]='b', ["Г"]='G', ["г"]='g', ["Ҕ"]='Ǧ', ["ҕ"]='ǧ',
	["Д"]='D', ["д"]='d', ["И"]='I', ["и"]='i', ["Й"]='J', ["й"]='j', ["К"]='K', ["к"]='k',
	["Л"]='L', ["л"]='l', ["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["Ӈ"]='Ŋ', ["ӈ"]='ŋ',
	["О"]='O', ["о"]='o', ["Ө"]='Ö', ["ө"]='ö', ["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r',
	["С"]='S', ["с"]='s', ["Һ"]='H', ["һ"]='h', ["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u',
	["Ү"]='Ü', ["ү"]='ü', ["Х"]='X', ["х"]='x', ["Ч"]='Č', ["ч"]='č', ["Ш"]='Š', ["ш"]='š',
	["Ы"]='Y', ["ы"]='y', ["Э"]='E', ["э"]='e',
	-- non-native letters
	["В"]='V', ["в"]='v', ["Е"]='Je', ["е"]='je', ["Ё"]='Jo', ["ё"]='jo', ["Ж"]='Ž', ["ж"]='ž',
	["З"]='Z', ["з"]='z', ["Ф"]='F', ["ф"]='f', ["Ц"]='C', ["ц"]='c', ["Щ"]='Ŝ', ["щ"]='ŝ',
	['Ъ']='ʺ', ['ъ']='ʺ', ["Ь"]="’", ["ь"]="’", ["Ю"]='Ju', ["ю"]='ju', ["Я"]='Ja', ["я"]='ja',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, 'Дь', 'Ď')
    text = mw.ustring.gsub(text, 'дь', 'ď')
    text = mw.ustring.gsub(text, 'Нь', 'Ń')
    text = mw.ustring.gsub(text, 'нь', 'ń')
	
    return (mw.ustring.gsub(text,'.',tab))
end

return export