Module:Tibt-Deva-translit

This module will transliterate text in the Tibetan script. 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:Tibt-Deva-translit/testcases.

Functions

edit
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 gsub = mw.ustring.gsub

local export = {}

local conv = {
	['ཀ']='क', ['ཫ']='क़', ['ཁ']='ख', ['ག']='ग', ['ང']='ङ',
	['ཅ']='च्य', ['ཆ']='छ्य', ['ཇ']='ज्य', ['འ']='अ',
	['ཙ']='च', ['ཚ']='छ', ['ཛ']='ज', ['ཉ']='ञ', ['ཞ']='श़', ['ཟ']='स़',
	['ཊ']='ट', ['ཋ']='ठ', ['ཌ']='ड', ['ཎ']='ण',
	['ཏ']='त', ['ཐ']='थ', ['ད']='द', ['ན']='न', ['ཨ']='अ',
	['པ']='प', ['ཕ']='फ', ['བ']='ब', ['བྷ']='भ', ['མ']='म',
	['ཡ']='य', ['ར']='र', ['ཬ']='ड़', ['ལ']='ल', ['ཤ']='श', ['ཝ']='व', 
    ['ཥ']='ष', ['ས']='स', ['ཧ']='ह', ['ྱ']='्य',

    ['ཱ']='ा', ['ི']='ि', ['ུ']='ु', ['ེ']='े', ['ོ']='ो', ['ཻ']='ै',
    ['ཽ']='ौ', ['྄']='्', ['་']=' ',
	-- chandrabindu    
	['ྃ']='ँ',
	-- anusvara    
	['ཾ']='ं',
	-- visarga    
	['ཿ']='ः',
	-- avagraha
	['྅']='ऽ',
	--punctuation
    ['༎']='॥',
	['།']='।',
	['ༀ']='ॐ',
    --Vedic extensions
    ['ྈ']='ᳵ', ['ྉ']='ᳶ',
}
function export.tr(text, lang, sc)
	text = gsub(
		text,
		".",
		function(c)
			return conv[c]
		end)
	text = gsub(text, 'गྷ', "घ")
	text = gsub(text, 'जྷ', "झ")
	text = gsub(text, 'डྷ', "ढ")
	text = gsub(text, 'दྷ', "ध")
	text = gsub(text, 'बྷ', "भ")
	text = gsub(text, 'लྷ', "ल्ह")
	text = gsub(text, 'रྷ', "र्ह")
	text = gsub(text, 'बྷ', "ह्")
	text = gsub(text, 'ྭ', "्व")
	text = gsub(text, 'ྲ', "्र")
	text = gsub(text, 'ྐ', "्क")
	text = gsub(text, 'ྑ', "्ख")
	text = gsub(text, 'ྒ', "्ग")
	text = gsub(text, 'ྒྷ', "्घ")
	text = gsub(text, 'ྜྷ', "्ढ")
	text = gsub(text, 'ྡྷ', "्ध")
	text = gsub(text, 'ྦྷ', "्भ")
	text = gsub(text, 'ྔ', "्ङ")
	text = gsub(text, 'ྟ', "्त")
	text = gsub(text, 'ྠ', "्थ")
	text = gsub(text, 'ྡ', "्द")
	text = gsub(text, 'ྚ', "्ट")
	text = gsub(text, 'ྛ', "्ठ")
	text = gsub(text, 'ྜ', "्ड")
	text = gsub(text, 'ྣ', "्न")
	text = gsub(text, 'ྤ', "्प")
	text = gsub(text, 'ྥ', "्फ")
	text = gsub(text, 'ྦ', "्ब")
	text = gsub(text, 'ྨ', "्म")
	text = gsub(text, 'ྙ', "्ञ")
	text = gsub(text, 'ྩ', "्च")
	text = gsub(text, 'ྪ', "्छ")
	text = gsub(text, 'ྫ', "्ज")
	text = gsub(text, 'ྕ', "्च्य")
	text = gsub(text, 'ྖ', "्छ्य")
	text = gsub(text, 'ྗ', "्ज्य")
	text = gsub(text, 'ླ', "्ल")
	text = gsub(text, 'ྴ', "्श")
	text = gsub(text, 'ྶ', "्स")
	text = gsub(text, 'ྵ', "्ष")
	text = gsub(text, 'ྸ', "्अ")
	text = gsub(text, 'रྀ', "ऋ")
	text = gsub(text, 'राྀ', "ॠ")
	text = gsub(text, '्ऋ', "ृ")
	text = gsub(text, '्ॠ', "ॄ")
	text = gsub(text, 'अा', "आ")
	text = gsub(text, 'अि', "इ")
	text = gsub(text, 'ाि', "ी")
	text = gsub(text, 'आि', "ई")
	text = gsub(text, 'अु', "उ")
	text = gsub(text, 'ाु', "ू")
	text = gsub(text, 'आु', "ऊ")
	text = gsub(text, 'अे', "ए")
	text = gsub(text, 'अै', "ऐ")
	text = gsub(text, 'अो', "ओ")
	text = gsub(text, 'अौ', "औ")
	return text
end
 
return export