Modul:dng-translit

Modul ini akan mentransliterasi Bahasa Dungan teks. 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:dng-translit/testcases.

Functions

sunting
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 = {
	['Б'] = 'B', ['П'] = 'P', ['М'] = 'M', ['Ф'] = 'F', ['В'] = 'V',
	['Д'] = 'D', ['Т'] = 'T', ['Н'] = 'N',              ['Л'] = 'L',
	['З'] = 'Z', ['Ц'] = 'C',              ['С'] = 'S',
	['Җ'] = 'Ž', ['Ч'] = 'Č',              ['Ш'] = 'Š', ['Ж'] = 'Ř',
	--[[  ↑  ]]  --[[  ↑  ]]               ['Щ'] = 'X',
	['Г'] = 'G', ['К'] = 'K', ['Ң'] = 'Ŋ', ['Х'] = 'H',
	                                                    ['Р'] = 'R',

	['Ы'] = 'Ɨ', ['Й'] = 'Y', ['Ў'] = 'W', ['Ү'] = 'Ü',
	--[[  ↑  ]]
	['А'] = 'A', ['Я'] = 'I͡a',
	['Ә'] = 'Ə', ['Е'] = 'I͡ə',
	['Э'] = 'E',
	['О'] = 'O', ['Ё'] = 'I͡o',
	['У'] = 'U', ['Ю'] = 'I͡u',

	['И'] = 'I',

	['б'] = 'b', ['п'] = 'p', ['м'] = 'm', ['ф'] = 'f', ['в'] = 'v',
	['д'] = 'd', ['т'] = 't', ['н'] = 'n',              ['л'] = 'l',
	['з'] = 'z', ['ц'] = 'c',              ['с'] = 's',
	['җ'] = 'ž', ['ч'] = 'č',              ['ш'] = 'š', ['ж'] = 'ř',
	--[[  ↑  ]]  --[[  ↑  ]]               ['щ'] = 'x',
	['г'] = 'g', ['к'] = 'k', ['ң'] = 'ŋ', ['х'] = 'h',
	                                                    ['р'] = 'r',

	['ы'] = 'ɨ', ['й'] = 'y', ['ў'] = 'w', ['ү'] = 'ü',
	--[[  ↑  ]]
	['а'] = 'a', ['я'] = 'i͡a',
	['ә'] = 'ə', ['е'] = 'i͡ə',
	['э'] = 'e',
	['о'] = 'o', ['ё'] = 'i͡o',
	['у'] = 'u', ['ю'] = 'i͡u',

	['и'] = 'i',
};

function export.tr(text, lang, sc)
	if (sc) and (sc ~= 'Cyrl') then
		return nil
	end

	text = mw.ustring.gsub(text, '.', tt)

	return text
end

return export