This module will transliterate Sundanese language text per WT:SU 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:su-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.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 .. 'a'
else
return consonants .. (diacritics or d)
end
else
if d == "" then
return consonants .. (special or s) .. 'a'
else
return consonants .. (special or s) .. (diacritics or d)
end
end
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export