Module:Cher-translit
Appearance
- The following documentation is located at Module:Cher-translit/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Cherokee script. It is used to transliterate Cherokee.
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:Cher-translit/testcases.
Functions
tr(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 m_cher = require("Module:Cher-common")
local m_str_utils = require("Module:string utilities")
local gsub = m_str_utils.gsub
-- transliteration export function
function export.tr(text, lang, sc)
-- ensure all Cherokee characters are uppercase
text = m_str_utils.upper(text)
-- substitute values generatively from syllable list dictionary
for c, v in pairs(m_cher.syl_list) do
for i, cher in ipairs(v) do
text = gsub(text, cher, c .. m_cher.vowel_order[i])
end
end
-- handle special cases for Ꮐ and Ꮝ
text = gsub(text, "Ꮐna", "Ꮐ'na") -- add apostrophe between Ꮐ and Ꮎ
text = gsub(text, "Ꮝ([aeiouv])", "Ꮝ'%1") -- add apostrophe between Ꮝ and a vowel
text = gsub(text, ".", {["Ꮐ"] = "nah", ["Ꮝ"] = "s"}) -- then substitute those values
return text
end
return export