Module:Translit-redirect
Appearance
local export = {}
local data = {
["pa"] = {
["debug_mode"] = true,
["Guru"] = {
["module"] = "Guru-translit",
},
["Deva"] = {
["module"] = "sa-translit",
},
["Arab"] = {
-- ["module"] = "pa-Arab-translit",
},
["pa-Arab"] = {
-- ["module"] = "pa-Arab-translit",
},
},
["khb"] = {
["Talu"] = {
["module"] = "Talu-translit",
},
["Lana"] = {
-- ["module"] = "Lana-translit",
},
["Thai"] = {
},
},
["qwm"] = {
["Latn"] = {
},
["Arab"] = {
},
["Armn"] = {
["module"] = "Armn-translit",
},
["error"] = "Huệ nương!",
},
["xpr"] = {
["Mani"] = {
["module"] = "Mani-translit",
},
["Latn"] = {
},
["Prti"] = {
},
["Phlv"] = {
},
["None"] = {
},
},
}
function export.tr(text, lang, sc, debug_mode)
local translit
if not sc then
sc = require("Module:scripts").findBestScript(text, require("Module:languages").getByCode(lang)):getCode()
end
local language_data = data[lang]
if language_data then
script_data = language_data[sc]
if script_data then
if script_data.module then
local success, translit_module = pcall(require, "Module:" .. script_data.module)
if success then
translit = translit_module.tr(text, lang, sc, debug_mode)
else
error(translit_module)
end
else
return nil
end
else
local err = language_data.error
if not err then
local canonical_names = mw.loadData("Module:languages/code to canonical name")
local script_names = mw.loadData("Module:scripts/code to canonical name")
err = script_names[sc] .. " is an invalid script for the " .. canonical_names[lang] .. " language."
end
error(err)
end
end
return translit
end
return export