https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AScripts%2Fprint Module:Scripts/print - Revision history 2025-05-31T00:44:03Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.3 https://en.wikipedia.org/w/index.php?title=Module:Scripts/print&diff=1185976300&oldid=prev Alexis Jazz: Imported page from https://en.wiktionary.org/wiki/Module:scripts/print AJsImportTool] 2023-11-20T04:04:45Z <p>Imported page from https://en.wiktionary.org/wiki/Module:scripts/print [<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 /> local function generate_table(name_to_code)<br /> local result = {}<br /> local script_data = mw.loadData(&quot;Module:scripts/data&quot;)<br /> <br /> local iterate<br /> if name_to_code then<br /> for code, data in pairs(script_data) do<br /> if not result[data[1]] or #code == 4 then<br /> -- Sometimes, multiple scripts have the same name, e.g. &#039;Arab&#039;,<br /> -- &#039;fa-Arab&#039;, &#039;ur-Arab&#039; and several others are called &quot;Arabic&quot;.<br /> -- Prefer the one with four characters when disambiguating.<br /> result[data[1]] = code<br /> end<br /> end<br /> else<br /> for code, data in pairs(script_data) do<br /> result[code] = data[1]<br /> end<br /> end<br /> <br /> return result<br /> end<br /> <br /> local function dump(data, name_to_code)<br /> local output = { &quot;return {&quot; }<br /> local i = 1<br /> local sorted_pairs = require &quot;Module:table&quot;.sortedPairs<br /> <br /> for k, v in sorted_pairs(data) do<br /> i = i + 1<br /> output[i] = (&#039;\t[%q] = %q,&#039;):format(k, v)<br /> end<br /> <br /> table.insert(output, &quot;}&quot;)<br /> <br /> return table.concat(output, &quot;\n&quot;)<br /> end<br /> <br /> function export.code_to_name(frame)<br /> return require &quot;Module:debug&quot;.highlight(dump(generate_table(false), false))<br /> end<br /> <br /> function export.name_to_code(frame)<br /> return require &quot;Module:debug&quot;.highlight(dump(generate_table(true), true))<br /> end<br /> <br /> return export</div> Alexis Jazz