Module:User:Erutuon/tools

local export = {}

local getScript = require("Module:scripts").findBestScript

local function getArgs(frame) local params = { [1] = { required = true }, [2] = { required = true }, }	local args = require("Module:parameters").process(frame.args, params) local langCode = args[1] local text = args[2] return langCode, text end

local function getLang(langCode) return require("Module:languages").getByCode(langCode) or require("Module:languages").err(langCode, 1) end

function export.script(frame) local langCode, text = getArgs(frame) local lang = getLang(langCode) local sc	if lang then sc = getScript(text, lang) end local dontReturn = { None = true, Latn = true, }	if sc and not dontReturn[sc:getCode] then return "|sc=" .. sc:getCode end end

function export.translit(frame) local langCode, text = getArgs(frame) local lang = getLang(langCode) local translit if lang then local sc = getScript(text, lang) translit = lang:transliterate(text, sc) end if translit then return "|tr=" .. translit end end

return export