Jump to content

Module:sat-translit

From Wiktionary, the free dictionary

This module will transliterate Santali language text. 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:sat-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 = {
	-- consonants
	['ᱛ'] = 't', ['ᱜ'] = 'g', ['ᱝ'] = 'ṅ', ['ᱞ'] = 'l',
	['ᱠ'] = 'k', ['ᱡ'] = 'j', ['ᱢ'] = 'm', ['ᱣ'] = 'w',
	['ᱥ'] = 's', ['ᱦ'] = 'h', ['ᱧ'] = 'ñ', ['ᱨ'] = 'r',
	['ᱪ'] = 'c', ['ᱫ'] = 'd', ['ᱬ'] = 'ṇ', ['ᱭ'] = 'y',
	['ᱯ'] = 'p', ['ᱰ'] = 'ḍ', ['ᱱ'] = 'n', ['ᱲ'] = 'ṛ',
	['ᱴ'] = 'ṭ', ['ᱵ'] = 'b', ['ᱶ'] = 'v', ['ᱷ'] = 'ʰ',

	-- consonants with ahad
	['ᱜᱽ'] = 'g’', ['ᱡᱽ'] = 'j’', ['ᱦᱽ'] = 'h’', ['ᱫᱽ'] = 'd’', ['ᱵᱽ'] = 'b’',
	
	-- vowels
	['ᱚ'] = 'ô', ['ᱟ'] = 'a', ['ᱤ'] = 'i', ['ᱩ'] = 'u', ['ᱮ'] = 'e', ['ᱳ'] = 'o',
	['ᱚᱹ'] = 'ô', ['ᱟᱹ'] = 'ə', ['ᱮᱹ'] = 'ɛ',
	['ᱚᱺ'] = 'ỗ', ['ᱟᱺ'] = 'ə̃', ['ᱮᱺ'] = 'ɛ̃',

	-- special stuff   
	['ᱸ']='̃',

	--numerals
	['᱐']='0', ['᱑']='1', ['᱒']='2', ['᱓']='3', ['᱔']='4', ['᱕']='5', ['᱖']='6', ['᱗']='7', ['᱘']='8', ['᱙']='9',

	--punctuation
	['᱾'] = '.', ['᱿'] = '.',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, '([᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙ᱚᱛᱜᱝᱞᱟᱠᱡᱢᱣᱤᱥᱦᱧᱨᱩᱪᱫᱬᱭᱮᱯᱰᱱᱲᱳᱴᱵᱶᱷᱸᱻᱼᱽ᱾᱿]ᱹ?ᱺ?)', tt)
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end
 
return export