Module:Cher-translit

local export = {} local gsub = mw.ustring.gsub

-- map latin consonants to Cherokee syllables where each consonant maps to a corresponding vowel local syl_list = { -- order of syllables: a, e, i, o, u, v	[""] = {"Ꭰ", "Ꭱ", "Ꭲ", "Ꭳ", "Ꭴ", "Ꭵ"}, k = {"Ꭷ"}, g = {"Ꭶ", "Ꭸ", "Ꭹ", "Ꭺ", "Ꭻ", "Ꭼ"}, h = {"Ꭽ", "Ꭾ", "Ꭿ", "Ꮀ", "Ꮁ", "Ꮂ"}, l = {"Ꮃ", "Ꮄ", "Ꮅ", "Ꮆ", "Ꮇ", "Ꮈ"}, m = {"Ꮉ", "Ꮊ", "Ꮋ", "Ꮌ", "Ꮍ", "Ᏽ"}, -- Ᏽ is obsolete n = {"Ꮎ", "Ꮑ", "Ꮒ", "Ꮓ", "Ꮔ", "Ꮕ"}, hn = {"Ꮏ"}, qu = {"Ꮖ", "Ꮗ", "Ꮘ", "Ꮙ", "Ꮚ", "Ꮛ"}, s = {"Ꮜ", "Ꮞ", "Ꮟ", "Ꮠ", "Ꮡ", "Ꮢ"}, d = {"Ꮣ", "Ꮥ", "Ꮧ", "Ꮩ", "Ꮪ", "Ꮫ"}, t = {"Ꮤ", "Ꮦ", "Ꮨ"}, dl = {"Ꮬ"}, tl = {"Ꮭ", "Ꮮ", "Ꮯ", "Ꮰ", "Ꮱ", "Ꮲ"}, ts = {"Ꮳ", "Ꮴ", "Ꮵ", "Ꮶ", "Ꮷ", "Ꮸ"}, w = {"Ꮹ", "Ꮺ", "Ꮻ", "Ꮼ", "Ꮽ", "Ꮾ"}, y = {"Ꮿ", "Ᏸ", "Ᏹ", "Ᏺ", "Ᏻ", "Ᏼ"} }

-- vowel order in Cherokee local vowel_order = {"a", "e", "i", "o", "u", "v"}

-- export for transliteration function export.tr(text, lang, sc) -- ensure all Cherokee characters are uppercase text = mw.ustring.upper(text)

-- substitute values in syl_list dictionary mappings for c, v in pairs(syl_list) do		for i, cher in ipairs(v) do text = gsub(text, cher, c .. vowel_order[i]) end end

-- handle special cases -- special case for Ꮐ text = gsub(text, "Ꮐna", "nah'na") -- add apostrophe if before Ꮎ text = gsub(text, "Ꮐ", "nah") -- otherwise append as is

-- special case for Ꮝ text = gsub(text, "Ꮝ([aeiouv])", "s'%1") -- add apostrophe if before a vowel text = gsub(text, "Ꮝ", "s") -- otherwise append as is

return text end

return export