Module:krv-script
Documentation for this module may be created at Module:krv-script/documentation
local export = {}
local getArgs = require("Module:Arguments").getArgs
local m_table = require("Module:table")
local correspondences = {
{"ẓ","ჟ"},
{"ṣ","შ"},
{"ṛ","ღ"},
{"ṇ","ჹ"},
{"ḥ","ხ"},
{"z","ზ"},
{"v","ვ"},
{"u","უ"},
{"th","თ"},
{"t","ტ"},
{"s","ს"},
{"r","რ"},
{"ph","ფ"},
{"p","პ"},
{"o","ო"},
{"n","ნ"},
{"m","მ"},
{"l","ლ"},
{"kh","ქ"},
{"k","კ"},
{"i","ი"},
{"h","ჰ"},
{"g","გ"},
{"f","ჶ"},
{"e","ე"},
{"dẓ","ჯ"},
{"dz","ძ"},
{"d","დ"},
{"c̣h","ჩ"},
{"c̣","ჭ"},
{"ch","ც"},
{"c","წ"},
{"b","ბ"},
{"a","ა"},
}
local correspondences_old = {
{"θ","ⴇ"},
{"β","ⴁ"},
{"ɸ","ⴔ"},
{"ɣ","ⴖ"},
{"ž","ⴏ"},
{"š","ⴘ"},
{"ŋ","ⴂ"},
{"čh","ⴙ"},
{"č","ჩ"},
{"ð","ⴃ"},
{"z","ⴆ"},
{"x","ⴞ"},
{"w","ⴣ"},
{"u","ⴓ"},
{"th","ⴇ"},
{"t","ⴒ"},
{"s","ⴑ"},
{"r","ⴐ"},
{"ph","ⴔ"},
{"p","ⴎ"},
{"o","ⴍ"},
{"n","ⴌ"},
{"m","ⴋ"},
{"l","ⴊ"},
{"kh","ⴕ"},
{"k","ⴉ"},
{"j","ⴢ"},
{"i","ⴈ"},
{"h","ⴠ"},
{"g","ⴂ"},
{"e","ⴄ"},
{"dž","ⴟ"},
{"dz","ⴛ"},
{"d","ⴃ"},
{"ch","ⴚ"},
{"c","ⴜ"},
{"b","ⴁ"},
{"a","ⴀ"},
}
function demacron(text)
text = mw.ustring.gsub(text, "ā", "a")
text = mw.ustring.gsub(text, "ē", "e")
text = mw.ustring.gsub(text, "ī", "i")
text = mw.ustring.gsub(text, "ō", "o")
text = mw.ustring.gsub(text, "ū", "u")
text = mw.ustring.gsub(text, "̄", "u")
return text
end
function convert(text, old)
local it = correspondences
if old then it = correspondences_old end
text = mw.ustring.lower(text)
text = demacron(text)
for _, c in ipairs(it) do
text = mw.ustring.gsub(text, c[1], c[2])
end
return text
end
function export.show(frame)
local args = getArgs(frame)
local parameters = {}
local text = ""
for i, arg in ipairs(args) do
if i == 1 then
text = arg
else
parameters[arg] = true
end
end
local script = convert(text, parameters["old"] or false)
local out = script
if parameters["both"] then
local delim = args["delim"] or " • "
local pre = args["pre"] or ""
local post = args["post"] or ""
if parameters["demacron"] then text = demacron(text) end
out = pre .. out .. delim .. text .. post
end
if parameters["inline"] then
return demacron(text) .. "<alt:" .. out .. ">"
else
return out
end
end
return export
--[[
Debug console test string:
=p.show(mw.getCurrentFrame():newChild{title="whatever",args={"nēphas"}})
]]--