模組:Deva-mnc-Mong-translit


This module will transliterate text in the 天城文. 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:Deva-mnc-Mong-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 = {
	{"(.[ःा-ॄेैो-्ॢॣ]*)([ँं])", "%2%1"}, {"(.[ःा-ॄेैो-्ॢॣ]*)(ऽ+)", "%2%1"},
	{"क", "ᡬᠠ"}, {"ख", "ᡘᠠ"}, {"ग", "ᡤᠠ"}, {"घ", "ᢚᠠ"}, {"ङ", "ᢛᠠ"}, 
	{"च", "ᢜᠠ"}, {"छ", "ᡮᠠ"}, {"ज", "ᡯᠠ"}, {"झ", "ᢝᠠ"}, {"ञ", "ᠨᡳᠶᠠ"}, 
	{"ट", "ᢞᠠ"}, {"ठ", "ᡱᠠ"}, {"ड", "ᡷᠠ"}, {"ढ", "ᢟᠠ"}, {"ण", "ᢏᠠ"}, 
	{"त", "ᢠᠠ"}, {"थ", "ᡨᠠ"}, {"द", "ᡩᠠ"}, {"ध", "ᢡᠠ"}, {"न", "ᠨᠠ"}, 
	{"प", "ᢒᠠ"}, {"फ", "ᡦᠠ"}, {"ब", "ᠪᠠ"}, {"भ", "ᢨᠠ"}, {"म", "ᠮᠠ"}, 
	{"य", "ᠶᠠ"}, {"र", "ᡵᠠ"}, {"ल", "ᠯᠠ"}, {"व", "ᠸᠠ"},
	{"श", "ᡧᠠ"}, {"ष", "ᢢᠠ"}, {"स", "ᠰᠠ"}, {"ह", "ᡥᠠ"},
	{"अ", "ᠠ"}, {"आ", "ᠠ᠎᠊ᠠ"}, {"इ", "ᡳ"}, {"ई", "ᡳᡳ"}, {"उ", "ᡠ"}, {"ऊ", "ᡠᡠ"}, {"ऋ", "ᡵᡳ"}, {"ॠ", "ᡵᡳᡳ"},
	{"ऌ", "ᠯᡳ"}, {"ॡ", "ᠯᡳᡳ"}, {"ए", "ᡝ"}, {"ऐ", "ᠠᡳ"}, {"ओ", "ᠣ"}, {"औ", "ᠣᠣ"},
	{"ँ", "ᢀ"}, {"ं", "ᢀ᠋"}, {"ः", "ᢁ"}, {"ऽऽऽ", "ᢆ"}, {"ऽ", "ᢅ"},
	{"०", "᠐"}, {"१", "᠑"}, {"२", "᠒"}, {"३", "᠓"}, {"४", "᠔"}, {"५", "᠕"}, {"६", "᠖"}, {"७", "᠗"}, {"८", "᠘"}, {"९", "᠙"},
	{"॥", "᠉ "}, {"।", "᠈ "},
	{"ᳵ", "ᢂ"}, {"ᳶ", "ᢄ"},
	{"ॐ", "ᢀᠣ"},
	{"-", "᠊"},
	{"(्)ᠸᠠ", "%1ᠣᠸᠠ"},
	{"ᠠा", "ᠠ᠎᠊ᠠ"}, {"ᠠि", "ᡳ"}, {"ᠠी", "ᡳᡳ"}, {"ᠠु", "ᡠ"}, {"ᠠू", "ᡠᡠ"}, {"ᠠृ", "ᡵᡳ"}, {"ᠠॄ", "ᡵᡳᡳ"},
	{"ᠠॢ", "ᠯᡳ"}, {"ᠠॣ", "ᠯᡳᡳ"}, {"ᠠे", "ᡝ"}, {"ᠠै", "ᠠᡳ"}, {"ᠠो", "ᠣ"}, {"ᠠौ", "ᠣᠣ"}, {"ᠠ्", ""},
	{"ᠯᡥ", "ᢪ"},
	{"ᠠ᠎᠊ᠠ([^᠊ᠠ-ᡸᢇ-ᢪ])", "ᠠᢇ%1"}, {"ᠠ᠎᠊ᠠ$", "ᠠᢇ"}, {"([᠊-᠏ᠠ-ᡸᢇ-ᢪ])ᠰ([^᠊ᠠ-ᡸᢇ-ᢪ])", "%1ᠰ᠌%2"}, {"([᠊-᠏ᠠ-ᡸᢇ-ᢪ])ᠰ", "%1ᠰ᠌"},
	{"([ᢅᢆ])(.᠋?)", "%2%1"},
	{"\n", " "}, {"<br>", " "},
	{" ([᠉᠈])", "%1"},
	{" +", " "}, {"^ +(.*)", "%1"}, {"(.*) +$", "%1"}
}
	
function export.tr(text)
	text = mw.ustring.lower(text)
	
	for _, replacement in ipairs(tt) do
		text = mw.ustring.gsub(text, replacement[1], replacement[2])
	end
	
	return text
end

return export