Module:ba-translit: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
m Fixed an issue where capital Ч gave lower-case č.
Anlztrk (talk | contribs)
Fixed transliterations in accordance with WT:BA TR
Line 3: Line 3:
local tt = {
local tt = {
["ү"]="ü", ['Ү']='Ü', ["т"]="t", ['Т']='T', ["р"]="r", ['Р']='R', ["ф"]="f", ['Ф']='F', ["ө"]="ö", ['Ө']='Ö',
["ү"]="ü", ['Ү']='Ü', ["т"]="t", ['Т']='T', ["р"]="r", ['Р']='R', ["ф"]="f", ['Ф']='F', ["ө"]="ö", ['Ө']='Ö',
["ю"]="yu", ['Ю']='Yu', ["ш"]="š", ['Ш']='Š', ["ь"]="’", ['Ь']='’', ["ъ"]="ʺ", ['Ъ']='ʺ', ["н"]="n", ['Н']='N',
["ю"]="yu", ['Ю']='Yu', ["ш"]="ş", ['Ш']='Ş', ["ь"]="’", ['Ь']='’', ["ъ"]="ʺ", ['Ъ']='ʺ', ["н"]="n", ['Н']='N',
["п"]="p", ['П']='P', ["й"]="y", ['Й']='Y', ["л"]="l", ['Л']='L', ["з"]="z", ['З']='Z', ["е"]="e", ['Е']='E',
["п"]="p", ['П']='P', ["й"]="y", ['Й']='Y', ["л"]="l", ['Л']='L', ["з"]="z", ['З']='Z', ["е"]="e", ['Е']='E',
["г"]="g", ['Г']='G', ["б"]="b", ['Б']='B', ["у"]="u", ['У']='U', ["с"]="s", ['С']='S', ["х"]="x", ['Х']='X',
["г"]="g", ['Г']='G', ["б"]="b", ['Б']='B', ["у"]="u", ['У']='U', ["с"]="s", ['С']='S', ["х"]="x", ['Х']='X',
["ч"]="č", ['Ч']='Č', ["щ"]="šč", ['Щ']='Šč', ["я"]="ya", ['Я']='Ya', ["ы"]="ï", ['Ы']='Ï', ["э"]="e", ['Э']='E',
["ч"]="ç", ['Ч']='Ç', ["щ"]="şç", ['Щ']='Şç', ["я"]="ya", ['Я']='Ya', ["ы"]="ı", ['Ы']='I', ["э"]="e", ['Э']='E',
["м"]="m", ['М']='M', ["о"]="o", ['О']='O', ["и"]="i", ['И']='I', ["ё"]="yo", ['Ё']='Yo', ["ж"]="ž", ['Ж']='Ž',
["м"]="m", ['М']='M', ["о"]="o", ['О']='O', ["и"]="i", ['И']='İ', ["ё"]="yo", ['Ё']='Yo', ["ж"]="c", ['Ж']='C',
["к"]="k", ['К']='K', ["д"]="d", ['Д']='D', ["в"]="v", ['В']='V', ["ц"]="ts", ['Ц']='Ts', ["а"]="a", ['А']='A',
["к"]="k", ['К']='K', ["д"]="d", ['Д']='D', ["в"]="v", ['В']='V', ["ц"]="ts", ['Ц']='Ts', ["а"]="a", ['А']='A',
["ң"]="ñ", ['Ң']='Ñ', ["ғ"]="ğ", ['Ғ']='Ğ', ["ҙ"]="ð", ['Ҙ']='Đ', ["ҡ"]="q", ['Ҡ']='Q', ["ҫ"]="θ", ['Ҫ']='Θ',
["ң"]="ñ", ['Ң']='Ñ', ["ғ"]="ğ", ['Ғ']='Ğ', ["ҙ"]="ż", ['Ҙ']='Ż', ["ҡ"]="q", ['Ҡ']='Q', ["ҫ"]="", ['Ҫ']='',
["һ"]="h", ['Һ']='H', ["ә"]="ä", ['Ә']='Ä'
["һ"]="h", ['Һ']='H', ["ә"]="ä", ['Ә']='Ä'
};
};

Revision as of 10:22, 21 February 2016

This module will transliterate Bashkir language text per WT:BA 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:ba-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 = {
	["ү"]="ü",  ['Ү']='Ü',  ["т"]="t",  ['Т']='T',  ["р"]="r",  ['Р']='R',  ["ф"]="f",  ['Ф']='F',  ["ө"]="ö", ['Ө']='Ö',
	["ю"]="yu", ['Ю']='Yu', ["ш"]="ş",  ['Ш']='Ş',  ["ь"]="’",  ['Ь']='’',  ["ъ"]="ʺ",  ['Ъ']='ʺ',   ["н"]="n", ['Н']='N', 
	["п"]="p",  ['П']='P',  ["й"]="y",  ['Й']='Y',  ["л"]="l",  ['Л']='L',  ["з"]="z",  ['З']='Z',  ["е"]="e", ['Е']='E', 
	["г"]="g",  ['Г']='G',  ["б"]="b",  ['Б']='B',  ["у"]="u",  ['У']='U',  ["с"]="s",  ['С']='S',  ["х"]="x", ['Х']='X',
	["ч"]="ç",  ['Ч']='Ç',  ["щ"]="şç", ['Щ']='Şç', ["я"]="ya", ['Я']='Ya', ["ы"]="ı",  ['Ы']='I',  ["э"]="e", ['Э']='E', 
	["м"]="m",  ['М']='M',  ["о"]="o",  ['О']='O',  ["и"]="i",  ['И']='İ',  ["ё"]="yo", ['Ё']='Yo', ["ж"]="c", ['Ж']='C',
	["к"]="k",  ['К']='K',  ["д"]="d",  ['Д']='D',  ["в"]="v",  ['В']='V',  ["ц"]="ts", ['Ц']='Ts', ["а"]="a", ['А']='A',
	["ң"]="ñ",  ['Ң']='Ñ',  ["ғ"]="ğ",  ['Ғ']='Ğ',  ["ҙ"]="ż",  ['Ҙ']='Ż',  ["ҡ"]="q",  ['Ҡ']='Q',  ["ҫ"]="ṡ", ['Ҫ']='Ṡ',
	["һ"]="h",  ['Һ']='H',  ["ә"]="ä",  ['Ә']='Ä'
};

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, "([АаЕеЭэЮюЯяӘәИиҮүУуӨөЫы])[үу]", "%1w") -- ү/у should be transliterated as w after vowels
	text = mw.ustring.gsub(
			text, "([АОӨӘУЫЕЯЁЮИЕаоөәуыэяёюиеъь%A][́̀]?)([Ее])",
			function(a,e) return a..(e=='е' and 'ye' or 'Ye') end
		):gsub("^Е",'Ye'):gsub("^е",'ye');
	text = mw.ustring.gsub(text, '.', tt)

	return text
end

return export