<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pttlink.org/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://wiki.pttlink.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ALanguages%2FList"/>
	<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:Languages/List&amp;action=history"/>
	<updated>2026-04-06T19:51:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://wiki.pttlink.org/index.php?title=Module:Languages/List&amp;diff=5764&amp;oldid=prev</id>
		<title>Kg7qin: Created page with &quot;local p = {};  local nativeList = require('Module:Multilingual description/sort') local nativeListIndex = {} for i, lang in ipairs(nativeList) do     nativeListIndex[lang] = i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:Languages/List&amp;diff=5764&amp;oldid=prev"/>
		<updated>2022-01-20T18:56:54Z</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('Module:Multilingual description/sort')&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;quot; .. table.concat(p.getSortedList(mw.language.fetchLanguageNames()), &amp;quot;', '&amp;quot;) .. &amp;quot;'}&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) ~= 'number' or k &amp;lt; 1 or k ~= math.floor(k)&lt;br /&gt;
            or type(v) ~= 'string' or #v &amp;lt; 2 or #v &amp;gt; 16&lt;br /&gt;
            or (v):find('^[a-z][%-0-9a-z]*[0-9a-z]$') ~= 1 then&lt;br /&gt;
                return false, ': invalid sequence of language codes in p.list[&amp;quot;' .. tostring(k) .. '&amp;quot;] = &amp;quot;' .. tostring(v) .. '&amp;quot;'&lt;br /&gt;
            end&lt;br /&gt;
            i = i + 1&lt;br /&gt;
        end&lt;br /&gt;
        if #(p.list) ~= i then return false, ': invalid sequence: length = '.. #(p.list) ' for ' .. i .. 'distinct keys' 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>Kg7qin</name></author>
	</entry>
</feed>