Module:Beng-Deva-translit

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

FunctionsEdit

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 U = mw.ustring.char
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local sub = mw.ustring.sub

local conv = {
	['ক']='क', ['খ']='ख', ['গ']='ग', ['ঘ']='घ', ['ঙ']='ङ',
	['চ']='च', ['ছ']='छ', ['জ']='ज', ['ঝ']='झ', ['ঞ']='ञ', 
	['ট']='ट', ['ঠ']='ठ', ['ড']='ड', ['ঢ']='ढ', ['ণ']='ण',
	['ত']='त', ['থ']='थ', ['দ']='द', ['ধ']='ध', ['ন']='न', 
	['প']='प', ['ফ']='फ', ['ব']='ब', ['ভ']='भ', ['ম']='म',
	['য']='य', ['র']='र', ['ল']='ल', ['শ']='श', 
    ['ষ']='ष', ['স']='स', ['হ']='ह',

	['া']='ा', ['ি']='ि', ['ী']='ी', ['ু']='ु', ['ূ']='ू', ['ৃ']='ृ', ['ৄ']='ॄ',
	['ৢ']='ॢ', ['ৣ']='ॣ', ['ে']='े', ['ৈ']='ै', ['ো']='ो', ['ৌ']='ौ',  ['্']='्', ['়']='़',

	-- vowels
	['অ']='अ', ['আ']='आ', ['ই']='इ', ['ঈ']='ई', ['উ']='उ', ['ঊ']='ऊ', ['ঋ']='ऋ', ['ৠ']='ॠ',
	['ঌ']='ऌ', ['ৡ']='ॡ', ['এ']='ए', ['ঐ']='ऐ', ['ও']='ओ', ['ঔ']='औ', 
	-- chandrabindu    
	['ঁ']='ँ',
	-- anusvara    
	['ং']='ं',
	-- visarga    
	['ঃ']='ः',
	-- avagraha
	['ঽ']='ऽ',
	--punctuation
    ['॥']='॥',
	['।']='।',
	['ওঁ']='ॐ',
    --Vedic extensions
    ['ᳵ']='ᳵ', ['ᳶ']='ᳶ',

		['০']='०', ['১']='१', ['২']='२', ['৩']='३', ['৪']='४',  ['৫']='५', ['৬']='६', ['৭']='७', ['৮']='८', ['৯']='९'
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		".",
		function(c)
			return conv[c]
		end)
	return text
end
 
return export