Module:Sund-translit: Difference between revisions
Jump to navigation
Jump to search
m Fenakhay moved page Module:su-translit to Module:Sund-translit without leaving a redirect |
m 1 revision imported |
(No difference)
| |
Latest revision as of 12:44, 21 April 2026
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Sundanese script. It is used to transliterate Baduy and Sundanese.
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:Sund-translit/testcases.
Functions
tr(text, lang, sc)- Transliterates a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the transliteration fails, returns
nil.
local export = {}
local consonants = {
['ᮊ']='k', ['ᮌ']='g', ['ᮍ']='ng', ['ᮎ']='c', ['ᮏ']='j', ['ᮑ']='ny',
['ᮒ']='t', ['ᮓ']='d', ['ᮔ']='n', ['ᮕ']='p', ['ᮘ']='b', ['ᮙ']='m',
['ᮚ']='y', ['ᮛ']='r', ['ᮜ']='l', ['ᮝ']='w', ['ᮞ']='s', ['ᮠ']='h',
['ᮖ']='f', ['ᮋ']='q', ['ᮗ']='v', ['ᮟ']='x', ['ᮐ']='z', ['ᮮ']='kh', ['ᮯ']='sy',
}
local diacritics = {
['ᮤ']= 'i' , ['ᮥ']='u' , ['ᮦ']='é' , ['ᮧ']='o' , ['ᮨ']='e' , ['ᮩ']='eu' ,
['ᮺ']='-a' , ['᮫']='' , ['᮪']='' ,
}
local special = {
['ᮬ']='m' , ['ᮭ']='w' , ['ᮡ']='y' , ['ᮢ']='r' , ['ᮣ']='l' ,
}
local nonconsonants = {
-- vowels
['ᮃ']='a' , ['ᮆ']='é' , ['ᮄ']='i' , ['ᮇ']='o' , ['ᮅ']='u' , ['ᮈ']='e' , ['ᮉ']='eu' , ['ᮻ']='reu' , ['ᮼ']='leu' ,
-- aditional characters
['|']='', -- digit pipe bar
['ᮀ']='ng',
['ᮁ']='r',
['ᮂ']='h',
['ᮾ']='k',
['ᮿ']='m',
-- digits
['᮰'] = '0', ['᮱'] = '1', ['᮲'] = '2', ['᮳'] = '3', ['᮴'] = '4',
['᮵'] = '5', ['᮶'] = '6', ['᮷'] = '7', ['᮸'] = '8', ['᮹'] = '9',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([ᮊᮌᮍᮎᮏᮑᮒᮓᮔᮕᮘᮙᮚᮛᮜᮝᮞᮠᮖᮋᮗᮟᮐᮮᮯ])'..
'([ᮬᮭᮡᮢᮣ]?)' ..
'([ᮤᮥᮦᮧᮨᮩᮺ ᮫᮪]?)',
function(c, s, d)
if s == "" then
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. (diacritics[d] or d)
end
else
if d == "" then
return consonants[c] .. (special[s] or s) .. 'a'
else
return consonants[c] .. (special[s] or s) .. (diacritics[d] or d)
end
end
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export