This module will transliterate text in the Kayah Li script. It is used to transliterate Western Kayah.
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:Kali-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 gsub = mw.ustring.gsub
local u = mw.ustring.char
local tt1 = {
-- consonants
= 'k', = 'hk', = 'g', = 'ng',
= 's', = 'hs', = 'z', = 'ny',
= 't', = 'ht', = 'n',
= 'p', = 'hp', = 'm',
= 'd', = 'b',
= 'r', = 'y', = 'l', = 'w',
= 'th', = 'h', = 'v', = 'c',
-- vowels
= 'a', = 'oe', = 'i', = 'o',
-- tones
= u(0x0301), = u(0x0300), = u(0x0304),
-- marks
= '-', = '.',
-- numerals
= '0', = '1', = '2', = '3', = '4',
= '5', = '6', = '7', = '8', = '9',
-- zero-width space (display it if it hides in a word)
= '‼',
}
local tt2 = {
-- vowels
= 'ue', = 'ae', = 'u',
= 'e', = 'oa',
= 'oeue', = 'ueae', = 'oeu',
= 'oee', = 'oeoa',
}
function export.tr(text, lang, sc)
if type(text) == 'table' then -- called directly from a template
text = text.args
end
text = gsub(text, '(*)()', '%1’%2') -- add apostrophe between adjacent two vowels
text = gsub(text, '()ꤟ(?)', '%1%2̤') -- change h between initial and vowel into subcolon
text = gsub(text, 'ꤟꤌꤣ', 'u'..u(0x0324)..'eoe') -- use u() to break Unicode normalization
text = gsub(text, 'ꤛꤣ', 'ueoe')
text = gsub(text, '', tt2)
text = gsub(text, '.', tt1)
text = gsub(text, '()(*)̤', '%1̤%2') -- move subcolon to first aeiou
text = gsub(text, '(̤?)(*)()', '%1%3%2') -- add tone mark on first aeiou
return text
end
return export