Module:Multilingual description/sort

From Wikimedia Commons, the free media repository
Jump to: navigation, search
Lua
CodeDiscussionEditHistoryQuick tests passed DocumentationSubpagesLinksTestsResultsSandbox All modules

Ordered by direction (all LTR scripts first, then RTL scripts), then by script, then alphabetically (by name) in each script.

Latin, Latin or Cyrillic, Cyrillic, Greek, Other simple LTR alphabets, Indic, Other South Asian, Syllabaries, Hangul, Japanese scripts, Sinograms, (RTL) Hebrew, (RTL) Arabic

Code

--[[
  The documented sort order is by script, then alphabetically by displayed native name (as generated by {{#language: code}}), using the default DUCET order.
  This allows easier selection by users reading the lists of languages in order to find their own.
  Please test this order, and maintain it as complete as possible, including legacy codes still used in MediaWiki.
  Any missing language will be sorted after all languages listed below, just using its internal language code.
]]
local p = {
-- LTR scripts
  -- Latin alphabets
    --[[A]] 'sma', 'ace', 'ang', 'af', 'ak', 'gsw', 'als', 'an', 'rup', 'roa-rup', 'frp', 'ast', 'gn', 'ay', 'az',
    --[[B]] 'bjn', 'id', 'ms', 'bm', 'nan', 'zh-min-nan', 'map-bms', 'jv', 'su', 'min', 'bbc', 'bbc-latn', 'bcl', 'bi', 'bar', 'bs', 'brh', 'br', 'en-gb',
    --[[C]] 'en-ca', 'cps', 'ca', 'ceb', 'cs', 'ch', 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'sei', 'co', 'cy',
    --[[D]] 'da', 'pdc', 'de', 'de-formal', 'nv', 'dsb', 'na', 'dtp',
    --[[E]] 'mh', 'et', 'egl', 'eml', 'en', 'es', 'eo', 'ext', 'eu', 'ee',
    --[[F]] 'hif', 'hif-latn', 'fo', 'fr', 'frc', 'fy', 'ff', 'fur',
    --[[G]] 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', 'aln', 'ki',
    --[[H]] 'ha', 'ha-latn', 'haw', 'ho', 'hsb', 'hr', 'hrx',
    --[[I]] 'io', 'ig', 'ilo', 'hil', 'ia', 'ie', 'ike-latn', 'ik', 'bto', 'xh', 'zu', 'is', 'it',
    --[[J]] 'jut',
    --[[K]] 'kl', 'kr', 'pam', 'csb', 'kw', 'krj', 'rw', 'kiu', 'rn', 'sw', 'kg', 'gom-latn', 'avk', 'ses', 'ht', 'gcf', 'kri', 'ku', 'ku-latn', 'kj',
    --[[L]] 'lad', 'ltg', 'la', 'lv', 'lzz', 'to', 'lb', 'lt', 'lij', 'li', 'ln', 'lfn', 'liv', 'jbo', 'lg', 'lmo',
    --[[M]] 'ary', 'hu', 'vmf', 'mg', 'mt', 'mi', 'arn', 'fit', 'cdo', 'mwl', 'lus', 'mus',
    --[[N]] 'fj', 'nah', 'nap', 'nl', 'nl-informal', 'nds-nl', 'cr', 'niu', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov',
    --[[O]] 'oc', 'om', 'ng', 'de-at', 'hz', 'uz', 'uz-latn',
    --[[P]] 'pfl', 'pag', 'pap', 'jam', 'pcd', 'pms', 'nds', 'pdt', 'pl', 'pt', 'pt-br', 'prg',
    --[[Q]] 'aa', 'kaa', 'kk-latn', 'kk-tr', 'crh', 'crh-latn',
    --[[R]] 'ty', 'ksh', 'ro', 'rmy', 'rgn', 'rm', 'qug', 'qu',
    --[[S]] 'se', 'sg', 'sat', 'sc', 'sdc', 'sli', 'de-ch', 'sco', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'loz', 'simple', 'ss', 'sk', 'sl', 'szl', 'so', 'srn', 'sr-latn', 'sr-el', 'fi', 'sv',
    --[[T]] 'tl', 'kab', 'roa-tara', 'rif', 'shi', 'shi-latn', 'tt-latn', 'tet', 'vi', 'tg-latn', 'tpi', 'tokipona', 'chy', 've', 'tr', 'tk', 'tru', 'tw',
    --[[U]] 'ug-latn',
    --[[V]] 'vot', 'za', 'vec', 'vep', 'ruq', 'ruq-latn', 'vo', 'vro', 'fiu-vro',
    --[[W]] 'wa', 'vls', 'war', 'wo',
    --[[X]] 'ts',
    --[[Y]] 'yo',
    --[[Z]] 'diq', 'zea', 'sgs', 'bat-smg',
  -- Latin OR Cyrillic alphabets
    'sh', -- most often Latin
    'sr', -- most often Cyrillic
  -- Cyrillic alphabets
    --[[А]] 'av', 'kbd', 'kbd-cyrl', 'ab',
    --[[Б]] 'ba', 'be', 'be-tarask', 'be-x-old', 'bxr', 'bg',
    --[[В]] 'ruq-cyrl',
    --[[Г]] 'inh',
    --[[И]] 'os',
    --[[К]] 'kv', 'krc', 'crh-cyrl', 'ky', 'mrj', 'kk', 'kk-cyrl', 'kk-kz',
    --[[Л]] 'lbe', 'lez',
    --[[М]] 'mk', 'mdf', 'mo', 'mn',
    --[[Н]] 'ce',
    --[[О]] 'mhr',
    --[[П]] 'koi',
    --[[Р]] 'rue', 'ru',
    --[[C]] 'sah', 'cu', 'sr-cyrl', 'sr-ec',
    --[[Т]] 'tt', 'tt-cyrl', 'tly', 'tg', 'tg-cyrl', 'tyv',
    --[[У]] 'udm', 'uz-cyrl', 'uk',
    --[[Х]] 'xal',
    --[[Ч]] 'cv',
    --[[Э]] 'myv',
  -- Greek or Coptic alphabets
    'grc', 'el', 'pnt',
  -- Other European alphabets
    'hy', 'xmf', 'ka',
  -- Devanagari abugidas
    'anp', 'ks-deva', 'new', 'ne', 'pi', 'bho', 'bh', 'mr', 'mai', 'sa', 'hi',
  -- Other North Indian abugidas
    'as', 'bn', 'bpy', 'pa',
  -- South Indian abugidas
    'gu', 'or', 'ta', 'te', 'kn', 'tcy', 'ml', 'si',
  -- Tibetan and other South-East Asian abugidas
    'th', 'my', 'dz', 'bo', 'lo', 'km',
  -- Syllabaries
    'ike-cans', 'iu', 'chr', 'bug', 'tzm', 'shi-tfng', 'ti', 'am', 'ii', 'got',
  -- Korean scripts (alphabet and sinograms) and Japanese scripts (syllabaries and sinograms)
    'ko', 'ko-kr', 'ko-kp', 'ja',
  -- Sinographic scripts (plus Bopomofo syllabary)
    'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'wuu', 'hak', 'yue', 'zh-yue', 'gan', 'gan-hans',
    'zh-hant', 'zh-tw',  'zh-mo', 'zh-hk', 'lzh', 'zh-classical', 'gan-hant',
-- RTL scripts
  -- Hebrew abjads
    'yi', 'ydd', 'he',
  -- Arabic abjads
    --[[ا]] 'ur', 'ar',
    --[[ب]] 'bqi', 'bgn', 'bcc',
    --[[پ]] 'ps', 'pnb',
    --[[ت]] 'azb', 'aeb',
    --[[ج]] 'arq',
    --[[س]] 'sd',
    --[[ف]] 'fa', 'fa-af', 'prd',
    --[[ق]] 'kk-arab', 'kk-cn',
    --[[ك]] 'ku-arab',
    --[[ک]] 'ks', 'ks-arab', 'khw', 'ckb',
    --[[گ]] 'glk',
    --[[ل]] 'lrc',
    --[[م]] 'mzn', 'arz',
    --[[ه]] 'ha-arab', 
    --[[ئ]] 'ug', 'ug-arab',
  -- Other semitics abjads
    'arc', 'dv',
-- Additions to sort

}

setmetatable(p, {
    quickTests = function()
        local i = 0
        for k, v in pairs(p) 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