Module:btx-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Karo Batak language text per WT:BTX TR.
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:btx-translit/testcases.
Functions
edittr(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
.
local export = {}
local consonants = {
['ᯀ']='(h)', ['ᯂ']='k', ['ᯅ']='b',
['ᯇ']='p', ['ᯉ']='n', ['ᯋ']='w',
['ᯎ']='g', ['ᯐ']='j', ['ᯑ']='d', ['ᯒ']='r', ['ᯔ']='m',
['ᯗ']='t', ['ᯘ']='s', ['ᯛ']='y',
['ᯝ']='ng', ['ᯞ']='l', ['ᯠ']='c', ['ᯡ']='c',
}
local diacritics = {
['ᯧ']= 'e' , ['ᯩ']='e' , ['ᯪ']='i' , ['ᯫ']='i' , ['ᯨ']='o' ,
['ᯭ']='o' , ['ᯬ']='u' , ['᯳']='' ,
}
local nonconsonants = {
-- vowels
['ᯤ']='i' , ['ᯥ']='u' ,
-- aditional characters
['ᯰ']='ng',
['ᯱ']='h',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([ᯀᯂᯅᯇᯉᯋᯎᯐᯑᯒᯔᯗᯘᯛᯝᯞᯠᯡ])'..
'([ᯧᯩᯪᯫᯨᯭᯬ᯳]?)',
function(c, d)
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. diacritics[d]
end
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export