Module:Cakm-translit

Hello, you have come here looking for the meaning of the word Module:Cakm-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Cakm-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Cakm-translit in singular and plural. Everything you need to know about the word Module:Cakm-translit you have here. The definition of the word Module:Cakm-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Cakm-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate text in the Chakma script. It is used to transliterate Chakma and Pali. 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:Cakm-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 u = require("Module:string/char")

-- Stage 1: IAST-style
local consonants = {
--consonants
-- 'ⓨ' is a convenience for language specific modifications. 
	='',
	='k', ='kh', ='g', ='gh', ='ṅ',
	='c', ='ch', ='j', ='jh', ='ñ', 
	='ṭ', ='ṭh', ='ḍ', ='ḍh', ='ṇ', 
	='t', ='th', ='d', ='dh', ='n', 
	='p', ='ph', ='b', ='bh', ='m',
	='y', ='ⓨ', ='r', ='l', ='v', ='v', 
--	='ś', ='ṣ',
	='s', ='h', ='ḷ',
}

local diacritics = {
--matras
	='ā', ='i', ='ī', ='u', ='ū',
--	='ṛ', ='ṝ', ='l̥', ='l̥̄',
	='e', ='ai', ='o', ='au',  ='',  ='',
    -- Oddities
    ='ă', ='oi', ='ei',
}

local tt = {

--vowels
	='a', ='i', ='u', ='e', 
	-- chandrabindu    
	='m̐', --until a better method is found
	-- anusvara    
	='ṃ', --until a better method is found
	-- visarga    
	='ḥ',
	--numerals
	='0', ='1', ='2', ='3', ='4', ='5', ='6', ='7', ='8', ='9',
	--punctuation        
	='.', --danda
    ='.', --double danda
    ='?', -- question mark
}

function export.tr(text, lang, sc)
	if sc ~= "Cakm" then
		return nil
	end
	
	text = mw.ustring.gsub(
		text,
		'()'.. -- consonant
		'(?)'.. -- vowel, joiner or no vowel
		'(?)', -- independent vowel 
		function(c, d, e)
			if d == "" and e ~= "" then        
				if tt == "i" or tt == "u" then return consonants .. 'a' .. tt .. '̈'
				else return consonants .. 'a' .. tt end
			elseif e ~= "" then
				return consonants .. diacritics .. tt
			elseif d == "" then        
				return consonants .. 'a'
			else
				return consonants .. diacritics
			end
		end)

	text = mw.ustring.gsub(text, '.', tt)
	if (lang == 'ccp') then
		text = mw.ustring.gsub(text, '.',
			{
				='a', ='ā', ='A',
--				='ṅ',
				='w',
				='ẏ' ,='y',
			})
		text = mw.ustring.gsub(text, 'ṃ$', 'ṅ')
	elseif (lang == 'pi') then
		text = mw.ustring.gsub(text, 'aḥ', 'ā')
	end
	if (lang == 'sa' or lang == 'pi') and mw.ustring.match(text, 'l̥') then
		text = mw.ustring.gsub(text, 'l̥', 'ḷ')
		text = mw.ustring.toNFC(text)
	end

	return text
end
 
return export