Module:Scripts/templates

local export = {}

function export.exists(frame) local args = frame.args local sc = args[1] or error("Script code has not been specified. Please pass parameter 1 to the module invocation.") sc = require("Module:scripts").getByCode(sc) if sc then return "1" else return "" end end

function export.getByCode(frame) local args = frame.args local sc = args[1] or error("Script code (parameter 1) has not been specified.") sc = require("Module:scripts").getByCode(sc, true)

return require("Module:language-like").templateGetByCode(sc, args,		function(itemname)			if itemname == "countCharacters" then				local text = args[3] or ""				return sc:countCharacters(text)			end		end	) end

function export.getByCanonicalName(frame) local args = frame.args local sc = args[1] or error("Script name (parameter 1) has not been specified.") sc = require("Module:scripts").getByCanonicalName(sc) if sc then return sc:getCode else return "None" end end

function export.findBestScript(frame) local args = frame.args local text = args[1] or error("Text to analyse (parameter 1) has not been specified.") local lang = args[2] or error("Language code (parameter 2) has not been specified.") local force_detect = args[3]; if force_detect == "" then force_detect = nil end lang = require("Module:languages").getByCode(lang, true) return require("Module:scripts").findBestScript(text, lang, force_detect):getCode end

return export