https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AScripts%2FprintModule:Scripts/print - Revision history2025-05-31T00:44:03ZRevision history for this page on the wikiMediaWiki 1.45.0-wmf.3https://en.wikipedia.org/w/index.php?title=Module:Scripts/print&diff=1185976300&oldid=prevAlexis 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&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 />
local function generate_table(name_to_code)<br />
local result = {}<br />
local script_data = mw.loadData("Module:scripts/data")<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. 'Arab',<br />
-- 'fa-Arab', 'ur-Arab' and several others are called "Arabic".<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 = { "return {" }<br />
local i = 1<br />
local sorted_pairs = require "Module:table".sortedPairs<br />
<br />
for k, v in sorted_pairs(data) do<br />
i = i + 1<br />
output[i] = ('\t[%q] = %q,'):format(k, v)<br />
end<br />
<br />
table.insert(output, "}")<br />
<br />
return table.concat(output, "\n")<br />
end<br />
<br />
function export.code_to_name(frame)<br />
return require "Module:debug".highlight(dump(generate_table(false), false))<br />
end<br />
<br />
function export.name_to_code(frame)<br />
return require "Module:debug".highlight(dump(generate_table(true), true))<br />
end<br />
<br />
return export</div>Alexis Jazz