Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Languages/List: Difference between revisions

From Neodyland Wiki
m +"aeb", "arq", "bbc", "bbc-latn", "bgn", "gom-latn", "hrx", "ses", "tzm", "uz-cyrl", "uz-latn" : now use builtin mw.language to get the sorted code list (static list commented out and compacted)
mNo edit summary
Line 28: Line 28:
p.list = p.getSortedList(mw.language.fetchLanguageNames())
p.list = p.getSortedList(mw.language.fetchLanguageNames())


 
setmetatable(p, {
    quickTests = function()
        local i = 0
        for k, v in pairs(p.list) do
            if type(k) ~= 'number' or k < 1 or k ~= math.floor(k)
            or type(v) ~= 'string' or #v < 2 or #v > 16
            or (v):find('^[a-z][%-0-9a-z]*[0-9a-z]$') ~= 1 then
                return false, ': invalid sequence of language codes in p["' .. tostring(k) .. '"] = "' .. tostring(v) .. '"'
            end
            i = i + 1
        end
        if #p ~= i then return false, ': invalid sequence: length = '.. #p ' for ' .. i .. 'distinct keys' end
        return true
    end
})
--[[ To test this module in the Lua console:
=getmetatable(p).quickTests() -- must return true
--]]
return p;
return p;
Cookies help us deliver our services. By using our services, you agree to our use of cookies.