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","ა"},
}
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")
return text
end
function convert(text)
text = mw.ustring.lower(text)
text = demacron(text)
for _, c in ipairs(correspondences) 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)
if parameters["both"] then
local delim = args["delim"] or " · "
if parameters["demacron"] then text = demacron(text) end
return script .. delim .. text
else
return script
end
end
return export
--[[
Debug console test string:
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"noun", "nom", "dv", "a^u", "n", "þ"}})
]]--