https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AScripts%2FtemplatesModule:Scripts/templates - Revision history2025-05-29T06:01:19ZRevision history for this page on the wikiMediaWiki 1.45.0-wmf.2https://en.wikipedia.org/w/index.php?title=Module:Scripts/templates&diff=1185976286&oldid=prevAlexis Jazz: Imported page from https://en.wiktionary.org/wiki/Module:scripts/templates AJsImportTool]2023-11-20T04:04:39Z<p>Imported page from https://en.wiktionary.org/wiki/Module:scripts/templates [<a href="/w/index.php?title=User:Alexis_Jazz/AJsImportTool.js&action=edit&redlink=1" class="new" title="User:Alexis Jazz/AJsImportTool.js (page does not exist)">AJsImportTool</a>]</p>
<p><b>New page</b></p><div>local export = {}<br />
<br />
function export.exists(frame)<br />
local args = frame.args<br />
local sc = args[1] or error("Script code has not been specified. Please pass parameter 1 to the module invocation.")<br />
<br />
sc = require("Module:scripts").getByCode(sc)<br />
<br />
if sc then<br />
return "1"<br />
else<br />
return ""<br />
end<br />
end<br />
<br />
function export.getByCode(frame)<br />
local args = frame.args<br />
local sc = require("Module:scripts").getByCode(args[1], 1, "disallow nil")<br />
<br />
return require("Module:language-like").templateGetByCode(sc, args,<br />
function(itemname)<br />
if itemname == "countCharacters" then<br />
local text = args[3] or ""<br />
return sc:countCharacters(text)<br />
end<br />
end<br />
)<br />
end<br />
<br />
function export.getByCanonicalName(frame)<br />
local args = frame.args<br />
local sc = args[1] or error("Script name (parameter 1) has not been specified.")<br />
<br />
sc = require("Module:scripts").getByCanonicalName(sc)<br />
<br />
if sc then<br />
return sc:getCode()<br />
else<br />
return "None"<br />
end<br />
end<br />
<br />
function export.findBestScript(frame)<br />
local args = frame.args<br />
local text = args[1] or error("Text to analyse (parameter 1) has not been specified.")<br />
local lang = args[2] or error("Language code (parameter 2) has not been specified.")<br />
local force_detect = args.force_detect; if force_detect == "" then force_detect = nil end<br />
local getCanonicalName = args[3] == "getCanonicalName"<br />
<br />
local sc = require("Module:languages").getByCode(lang, true):findBestScript(text, force_detect)<br />
<br />
if getCanonicalName then<br />
return sc:getCanonicalName()<br />
else<br />
return sc:getCode()<br />
end<br />
end<br />
<br />
return export</div>Alexis Jazz