This module will transliterate Kaitag language text per WT:XDQ 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:xdq-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 m_str_utils = require("Module:string utilities")
local gsub = m_str_utils.gsub
local sub = m_str_utils.sub
local upper = m_str_utils.upper
local lower = m_str_utils.lower
local len = m_str_utils.len
local letters = {
= "m", = "n", = "b", = "d", = "g",
= "p", = "t", = "k", = "q", = "ʼ",
= "c", = "č",
= "v", = "z", = "ž", = "ɣ",
= "s", = "š", = "x", = "χ", = "h",
= "r", = "l", = "y",
= "i", = "u", = "e", = "a", = "o", = "æ",
-- Ejectives
= "ṗ", = "ṭ", = "ḳ", = "q̇",
= "c̣", = "č̣",
-- Dialectal letters
= "ʡ", = "ħ",
}
-- Generate upper-case and title-case variants
local mappings = {}
for k, v in pairs(letters) do
mappings = v
mappings = upper(v)
if len(k) == 2 then
mappings = gsub(v, "^.", upper)
end
end
function export.tr(text, lang, sc)
local result = {}
local i = 1
while i <= len(text) do
local one = sub(text, i, i)
local two = one .. sub(text, i + 1, i + 1)
local mapped = one
if two ~= one and mappings then
mapped = mappings
i = i + 1 -- Skip next character if digraph matched
elseif mappings then
mapped = mappings
end
table.insert(result, mapped)
i = i + 1
end
return table.concat(result)
end
return export