https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AScripts%2Ftemplates Module:Scripts/templates - Revision history 2025-05-29T06:01:19Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.2 https://en.wikipedia.org/w/index.php?title=Module:Scripts/templates&diff=1185976286&oldid=prev Alexis 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&amp;action=edit&amp;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(&quot;Script code has not been specified. Please pass parameter 1 to the module invocation.&quot;)<br /> <br /> sc = require(&quot;Module:scripts&quot;).getByCode(sc)<br /> <br /> if sc then<br /> return &quot;1&quot;<br /> else<br /> return &quot;&quot;<br /> end<br /> end<br /> <br /> function export.getByCode(frame)<br /> local args = frame.args<br /> local sc = require(&quot;Module:scripts&quot;).getByCode(args[1], 1, &quot;disallow nil&quot;)<br /> <br /> return require(&quot;Module:language-like&quot;).templateGetByCode(sc, args,<br /> function(itemname)<br /> if itemname == &quot;countCharacters&quot; then<br /> local text = args[3] or &quot;&quot;<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(&quot;Script name (parameter 1) has not been specified.&quot;)<br /> <br /> sc = require(&quot;Module:scripts&quot;).getByCanonicalName(sc)<br /> <br /> if sc then<br /> return sc:getCode()<br /> else<br /> return &quot;None&quot;<br /> end<br /> end<br /> <br /> function export.findBestScript(frame)<br /> local args = frame.args<br /> local text = args[1] or error(&quot;Text to analyse (parameter 1) has not been specified.&quot;)<br /> local lang = args[2] or error(&quot;Language code (parameter 2) has not been specified.&quot;)<br /> local force_detect = args.force_detect; if force_detect == &quot;&quot; then force_detect = nil end<br /> local getCanonicalName = args[3] == &quot;getCanonicalName&quot;<br /> <br /> local sc = require(&quot;Module:languages&quot;).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