Module:gon-Gonm-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:gon-Gonm-translit/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
Masaram Gondi transliteration module.
This module will transliterate Gondi 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:gon-Gonm-translit/testcases.
Functions
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
Testcases
[edit]Module:gon-Gonm-translit/testcases:
All tests passed. (refresh)
Text | Expected | Actual | Comments | |
---|---|---|---|---|
𑴦𑴶 | r̥ | r̥ | independent <r̥> represented by independent <r> + dependent <r̥> | |
𑴨𑴘𑵂𑴳 | vaṛī | vaṛī | <ṛ> represented as 𑴘𑵂 | |
𑴀𑴎𑵅𑴎 | agga | agga | virama | |
𑴌𑴱𑴖𑵄 | kāṭ | kāṭ | word-final halanta | |
𑴌𑴵𑴥𑵄𑴫𑴱 | kūysā | kūysā | word-medial halanta | |
𑴀𑵆𑴝𑴽 | ardo | ardo | repha | |
𑴑𑴱𑴠𑵇𑴱 | cāprā | cāprā | ra-kāra | |
𑴆𑵃 | ĕ | ĕ | <ऍ> ĕ independent | |
𑴁𑵃 | ŏ | ŏ | <ऑ> ŏ independent | |
𑴌𑵃 | kĕ | kĕ | <ऍ> ĕ dependent | |
𑴌𑴱𑵃 | kŏ | kŏ | <ऑ> ŏ dependent |
local export = {}
local gsub = mw.ustring.gsub
local consonants = {
['𑴌'] = 'k', ['𑴍'] = 'kh', ['𑴎'] = 'g', ['𑴏'] = 'gh', ['𑴐'] = 'ṅ',
['𑴑'] = 'c', ['𑴒'] = 'ch', ['𑴓'] = 'j', ['𑴔'] = 'jh', ['𑴕'] = 'ñ',
['𑴖'] = 'ṭ', ['𑴗'] = 'ṭh', ['𑴘'] = 'ḍ', ['𑴙'] = 'ḍh', ['𑴚'] = 'ṇ',
['𑴛'] = 't', ['𑴜'] = 'th', ['𑴝'] = 'd', ['𑴞'] = 'dh', ['𑴟'] = 'n',
['𑴠'] = 'p', ['𑴡'] = 'ph', ['𑴢'] = 'b', ['𑴣'] = 'bh', ['𑴤'] = 'm',
['𑴥'] = 'y', ['𑴦'] = 'r', ['𑴧'] = 'l', ['𑴨'] = 'v', ['𑴭'] = 'ḷ',
['𑴩'] = 'ś', ['𑴪'] = 'ṣ', ['𑴫'] = 's', ['𑴬'] = 'h',
['𑴮'] = 'kṣ', ['𑴯'] = 'jñ', ['𑴰'] = 'tr',
['𑴘𑵂'] = 'ṛ',
}
local diacritics = {
['𑴱'] = 'ā', ['𑴲'] = 'i', ['𑴳'] = 'ī', ['𑴴'] = 'u', ['𑴵'] ='ū', ['𑴶'] = 'r̥',
['𑴺'] = 'e', ['𑴼'] = 'ai', ['𑴽'] ='o', ['𑴿'] = 'au', ['𑵄'] = '', ['𑵅'] = '',
}
local tt = {
-- vowels
['𑴀'] = 'a' , ['𑴁'] = 'ā' , ['𑴂'] = 'i' , ['𑴃'] = 'ī' , ['𑴄']='u' , ['𑴅'] = 'ū',
['𑴆'] = 'e', ['𑴈'] = 'ai' , ['𑴉'] = 'o', ['𑴋'] = 'au',
-- other symbols
['𑵀'] = 'ṁ', -- anusvara
['𑵁'] = 'ḥ', -- visarga
['𑵃'] = '̃', -- chandra
-- digits
['𑵐'] = '0', ['𑵑'] = '1', ['𑵒'] = '2', ['𑵓'] = '3', ['𑵔'] = '4',
['𑵕'] = '5', ['𑵖'] = '6', ['𑵗'] = '7', ['𑵘'] = '8', ['𑵙'] = '9',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = gsub(text, '𑵇', '𑵄𑴦') -- ra-kāra
text = gsub(
text,
'([𑴌-𑴰]𑵂?)'..
'([[𑴱𑴲𑴳𑴴𑴵𑴶𑴺𑴼𑴽𑴿𑵀𑵁𑵄𑵅]?)',
function(c, d)
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. diacritics[d]
end
end)
text = gsub(text, '.', tt)
-- anusvara
text = gsub(text, 'ṁ([kgṅ])', 'ṅ%1')
text = gsub(text, 'ṁ([cjñ])', 'ñ%1')
text = gsub(text, 'ṁ([ṭḍṇ])', 'ṇ%1')
text = gsub(text, 'ṁ([tdn])', 'n%1')
text = gsub(text, 'ṁ([pbm])', 'm%1')
text = gsub(text, 'rr̥', 'r̥') -- 𑴦𑴶 is independent r̥
text = gsub(text, '𑵆', 'r') -- repha
text = gsub(text, '[ea]̃', 'ĕ') -- <ऍ> ĕ independent and dependent
text = gsub(text, 'ā̃', 'ŏ') -- <ऑ> ŏ independent and dependent
return text
end
return export