<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Module%3ALanguages%2FList</id>
	<title>Module:Languages/List - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Module%3ALanguages%2FList"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Languages/List&amp;action=history"/>
	<updated>2026-04-09T04:52:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Module:Languages/List&amp;diff=16292&amp;oldid=prev</id>
		<title>Caleb Cooper: Created page with &quot;local p = {};  local nativeList = require(&#039;Module:Multilingual description/sort&#039;) local nativeListIndex = {} for i, lang in ipairs(nativeList) do     nativeListIndex[lang] = i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Languages/List&amp;diff=16292&amp;oldid=prev"/>
		<updated>2021-05-08T12:29:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {};  local nativeList = require(&amp;#039;Module:Multilingual description/sort&amp;#039;) local nativeListIndex = {} for i, lang in ipairs(nativeList) do     nativeListIndex[lang] = i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {};&lt;br /&gt;
&lt;br /&gt;
local nativeList = require(&amp;#039;Module:Multilingual description/sort&amp;#039;)&lt;br /&gt;
local nativeListIndex = {}&lt;br /&gt;
for i, lang in ipairs(nativeList) do&lt;br /&gt;
    nativeListIndex[lang] = i&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
--[[ Check this list by running this in the console of the Lua Module editor in MediaWiki:&lt;br /&gt;
=&amp;quot;p.list = {&amp;#039;&amp;quot; .. table.concat(p.getSortedList(mw.language.fetchLanguageNames()), &amp;quot;&amp;#039;, &amp;#039;&amp;quot;) .. &amp;quot;&amp;#039;}&amp;quot;&lt;br /&gt;
]]&lt;br /&gt;
function p.getSortedList(mwLangList)&lt;br /&gt;
    local sortedList = {}&lt;br /&gt;
    for lang, _ in pairs(mwLangList) do&lt;br /&gt;
        table.insert(sortedList, lang)&lt;br /&gt;
    end&lt;br /&gt;
    pcall(function()&lt;br /&gt;
        table.sort(sortedList, function(lang1, lang2)&lt;br /&gt;
            return (nativeListIndex[lang1] or -1) &amp;lt;= (nativeListIndex[lang2] or -1)&lt;br /&gt;
        end)&lt;br /&gt;
    end)&lt;br /&gt;
    return sortedList&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- note that this fetch will be costly if all these languages are loaded individually with their data by Mediawiki&lt;br /&gt;
p.list = p.getSortedList(mw.language.fetchLanguageNames())&lt;br /&gt;
&lt;br /&gt;
setmetatable(p, {&lt;br /&gt;
    quickTests = function()&lt;br /&gt;
        local i = 0&lt;br /&gt;
        for k, v in pairs(p.list) do&lt;br /&gt;
            if type(k) ~= &amp;#039;number&amp;#039; or k &amp;lt; 1 or k ~= math.floor(k)&lt;br /&gt;
            or type(v) ~= &amp;#039;string&amp;#039; or #v &amp;lt; 2 or #v &amp;gt; 16&lt;br /&gt;
            or (v):find(&amp;#039;^[a-z][%-0-9a-z]*[0-9a-z]$&amp;#039;) ~= 1 then&lt;br /&gt;
                return false, &amp;#039;: invalid sequence of language codes in p.list[&amp;quot;&amp;#039; .. tostring(k) .. &amp;#039;&amp;quot;] = &amp;quot;&amp;#039; .. tostring(v) .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
            end&lt;br /&gt;
            i = i + 1&lt;br /&gt;
        end&lt;br /&gt;
        if #(p.list) ~= i then return false, &amp;#039;: invalid sequence: length = &amp;#039;.. #(p.list) &amp;#039; for &amp;#039; .. i .. &amp;#039;distinct keys&amp;#039; end&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
})&lt;br /&gt;
--[[ To test this module in the Lua console:&lt;br /&gt;
=getmetatable(p).quickTests() -- must return true&lt;br /&gt;
--]]&lt;br /&gt;
return p;&lt;/div&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
</feed>