Module:Multilingual description/sort

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code 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 LTR alphabets, Indic, Other South Asian, Syllabaries, Hangul, Japanese scripts, Sinograms, vertical scripts (rendered horizontally LTR, unless explicitly rotated by style), (RTL) Hebrew, Arabic, Divehi, N'Ko.

You can see a comprehensive test of rendering (and other checks) of language codes and native names on Module talk:Multilingual description/sort/testcases: the table will be sorted accordingly (If you see green rows at the bottom, there are missing languages to add into this sort list).

Additionally you should map the writing directions ("rtl" or "ltr") of all these languages in Module:Dir/RTL overrides to avoid fallbacks to a costly MediaWiki API (if it knows the language) or a last-chance fallback to "ltr" (which may be incorrect).

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', 'agq', 'ak', 'gsw', 'als', 'en-us', 'ase', 'smn', 'an', 'aae', 'rup', 'roa-rup', 'frp', 'ast', 'atj', 'gn', 'ay', 'az',
    --[[B]] 'ksf', 'bfd', 'abs', 'gor', 'id', 'ms', 'bdr', 'bkc', 'bkh', 'bm', 'bax', 'nan', 'zh-min-nan', 'bjn', 'ban', 'jv-x-bms', 'map-bms', 'kge', 'bug', 'bug-latn', 'bas', 'btm', 'bbc', 'bbc-latn', 'bew', 'sje', 'bcl', 'bi', 'bar', 'bs', 'brh', 'br', 'en-gb',
    --[[C]] 'en-ca', 'cps', 'ca', 'ceb', 'cs', 'cho', 'ch', 'cbk-zam', 'ny', 'chn', 'sn', 'tum', 'sei', 'co', 'cy',
    --[[D]] 'dga', 'dag', 'da', 'se', 'se-no', 'se-se', 'se-fi', 'pdc', 'de', 'de-formal', 'de-at', 'de-ch', 'de-latf', 'nv', 'dsb', 'non'--[[Dǫnsk tunga]], 'na', 'dua', 'dtp',
    --[[E]] 'mh', 'et', 'efi', 'etu', 'vmw', 'egl', 'eml', 'en', 'es', 'es-formal', 'es-419', 'eo', 'ext', 'eto', 'eu', 'ee', 'ewo',
    --[[F]] 'wls', 'gur', 'fmp', 'hif', 'hif-latn', 'fil', 'fon', 'fo', 'fr', 'frc', 'fy', 'ff', 'fur',
    --[[G]] 'gaa', 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', 'aln', 'gya', 'gpe', 'bbj', 'ki', 'gom-latn', 'guw',
    --[[H]] 'cnh', 'ha', 'ha-latn', 'haw', 'ho', 'hmn', 'hsb', 'hr', 'hrx',
    --[[I]] 'ibb', 'io', 'igl', 'ig', 'rw', 'rn', 'ilo', 'hil', 'ia', 'ie', 'ike-latn', 'ik', 'bto', 'xh', 'zu', 'is', 'isu', 'it',
    --[[J]] 'jv', 'smj', 'jut',
    --[[K]] 'rmf', 'kbp', 'kea', 'kl', 'kr', 'pam', 'cak', 'kai', 'krl', 'csb', 'ker', 'kw', 'krj', 'kiu', 'sw', 'bkm', 'kg', 'avk', 'ses', 'ht', 'kri', 'gcf'--[[kréyòl gwadloupéyen]], 'gcr', 'ku', 'ku-latn', 'kmr', 'kmr-latn', 'kus', 'fkv', 'kj', 'nmg',
    --[[L]] 'jbo', 'lld', 'lad', 'lns', 'ltg', 'la', 'lv', 'lzz', 'to', 'lb', 'nia', 'lt', 'lij', 'li', 'ln', 'lfn', 'liv', 'olo', 'lmo', 'lg',
    --[[M]] 'mad', 'hu', 'hu-formal', 'vmf', 'mcp', 'mg', 'mt', 'mnc-latn', 'mi', 'mrh', 'arn', 'srq', 'fit', 'byv', 'fat', 'min', 'cdo', 'mwl', 'lus', 'bqz', 'mos', 'mua', 'mus',
    --[[N]] 'fj', 'nah', 'pcm', 'nap', --[['nrm', should be Narom]] 'nmz', 'nnz', 'nl', 'nl-informal', 'nds-nl', 'cr', 'nnh', 'nla', 'nge', 'yrl', 'niu', 'lem', 'frr', 'pih', 'no', 'nb', 'nn', 'nrf'--[[Nouormand]], 'nrm'--[[currently Nouormand, should be Narom instead]], 'nov', 'yas', 'sms', 'nys',
    --[[O]] 'uz-latn', 'uz', 'ann', 'oc', 'ojb', 'om', 'nyo', 'ttj', 'ng', 'de-at', 'hz',
    --[[P]] 'pfl', 'pag', 'ami', 'pap', 'pap-aw', 'jam', 'pcd', 'wes', 'pms', 'pwn', 'nds', 'pdt', 'cpx-latn', 'pl', 'pt', 'pt-br', 'prg',
    --[[Q]] 'aa', 'kaa', 'quc', 'kk-latn', 'kk-tr', 'crh', 'crh-latn',
    --[[R]] 'ty', 'ksh', 'ro', 'rmc', 'rmy', 'rgn', 'rm', 'qug', 'qu', 'nyn',
    --[[S]] 'xsy', 'szy', 'sg', 'sc', 'sro', 'sdc', 'sli', 'de-ch', 'sco', 'trv', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'loz', 'simple', 'ss', 'sk', 'sl', 'szl', 'so', 'srn', 'sr-latn', 'sr-el', 'sh'--[[latn/cyrl]], 'sh-latn', 'sh-el', 'su', 'fi', 'sv',
    --[[T]] 'shy', 'shy-latn', 'tl', 'tzl', 'kab', 'scn-x-tara', 'roa-tara', 'rif', 'shi', 'shi-latn', 'tt-latn', 'crh-ro', 'tay', 'tet', 'din', 'vi', 'tg-latn', 'tpi', 'tok', 'tly', 'chy', 've', 'bag', 'tvu', 'aeb-latn', 'tr', 'tk', 'tru', 'tw', 'kcg',
    --[[U]] 'sju', 'ug-latn',
    --[[V]] 'vot', 'za', 'vec', 'vep', 'ruq', 'ruq-latn', 'vo', 'vro', 'fiu-vro', 'mcn', 'vut',
    --[[W]] 'wa', 'bci', 'guc', 'osa-latn', 'vls', 'wal', 'war', 'wo', 'wya',
    --[[X]] 'ts',
    --[[Y]] 'yat', 'ybb', 'yav', 'yo',
    --[[Z]] 'diq', 'zea', 'sgs', 'bat-smg',
  -- Greek and Coptic alphabets
    'grc', 'el', 'pnt',
    'cop',
  -- Cyrillic alphabets
    --[[А]] 'av', 'ady', 'ady-cyrl', 'kbd', 'kbd-cyrl', 'ab', 'alt',
    --[[Б]] 'ba', 'be', 'be-tarask', 'be-x-old', 'bxr', 'bg',
    --[[В]] 'ruq-cyrl',
    --[[Г]] 'inh',
    --[[И]] 'os',
    --[[К]] 'sjd', 'kv', 'krc', 'kum', 'crh-cyrl', 'ky', 'mrj', 'kk', 'kk-cyrl', 'kk-kz',
    --[[Л]] 'lbe', 'lez',
    --[[М]] 'mk', 'mdf', 'mo', 'mn', 'rut',
    --[[Н]] 'gld', 'nog', 'ce',
    --[[О]] 'mhr',
    --[[П]] 'koi',
    --[[Р]] 'rue', 'rsk', 'ru',
    --[[C]] 'sah', 'sty', 'cu', 'sr-cyrl', 'sr-ec', 'sr'--[[cyrl/latn]], 'sh-cyrl', 'sh-ec',
    --[[Т]] 'tt-cyrl', 'tt', 'tly-cyrl', 'tg-cyrl', 'tg', 'tyv',
    --[[У]] 'udm', 'uz-cyrl', 'uk',
    --[[Х]] 'kjh', 'xal',
    --[[Ч]] 'cv',
    --[[Э]] 'myv',
  -- Other alphabets (horizontal only)
    'xmf', 'ka',
    'hyw', 'hy',
  -- Devanagari abugidas
    'anp', 'awa', 'xnr-deva', 'xnr', 'ks-deva', 'ks', 'gom-deva', 'gom', 'dgo-deva', 'dgo', 'doi-deva', 'doi', 'dty', 'new', 'ne', 'pi', 'bho', 'bh', 'mag', 'mr', 'rwr', 'mai', 'sa', 'hi',
  -- Bengali abugidas
    'as', 'rkt', 'bn', 'bpy',
  -- Other North Indian abugidas
    'pa',
    'syl',
    'xnr-takr', 'doi-takr', 'dgo-takr',
  -- South Indian abugidas
    'gu',
    'or',
    'ta',
    'nit', 'te',
    'kn', 'tcy',
    'ml',
    'si',
  -- Tibeto-Burmese abugidas
    'dz', 'bo',
    'mni',
    'ksw', 'blk', 'kjp', 'shn', 'mnw', 'my', 'rki',
  -- Other Central and South-Eastern Asian abugidas
    'km',
    'lo',
    'tdd',
    'nod',
    'th',
    'bug-bugi',
    'ban-bali',
    'sat',
  -- North-Western syllabaries
    'chr',
    'ike-cans', 'iu',
    'got',
  -- African syllabaries
    'tzm', 'zgh', 'shi-tfng', 'rif-tfng', 'sjs',
    'ti', 'am',
  -- Asian syllabaries
    'ii',
  -- Korean scripts (alphabet and sinograms)
    'ko-kp', 'ko', 'ko-kr',
  -- Japanese scripts (syllabaries and sinograms)
    'ja', 'ryu',
  -- Sinographic scripts (plus Bopomofo syllabary)
    'zh', 'zh-cn', 'zh-tw', 'zh-sg', 'zh-mo', 'zh-hans', 'zh-hant', 'zh-hk', 'zh-my',
    'wuu-hant', 'wuu', 'wuu-hans',
    'hak',
    'lzh', 'zh-classical',
    'hsn',
    'yue', 'zh-yue', 'yue-hant', 'yue-hans',
    'cpx', 'cpx-hant', 'cpx-hans',
    'gan', 'gan-hant', 'gan-hans', 'nan-hani',
-- Other vertical scripts (that are rendered horizontally, when not rotated explicitly by style)
    'mnc-mong', 'mnc',
-- RTL scripts
  -- Hebrew abjads
    'yi', 'ydd', 'yih', 'he', 'hbo',
  -- Arabic abjads
    --[[ء]] -- [[ٴ]]
    --[[ا]] 'ur', 'ary', 'ar', 'acm', 'acq', 'uz-arab',
      --[[أ]] --[[ٱ]] --[[ٳ]] --[[ٲ]] --[[ا]] --[[آ]]
    --[[ب]] 'bqi', 'bsk', 'bgp' ,'bal', 'ms-arab',
      --[[ب]] --[[ٻ]] --[[ڀ]]
      --[[پ]] 'ps', 'pnb',
      --[[ت]] 'aeb-arab', 'aeb', 'azb',
      --[[ٺ]] --[[ٿ]] --[[ټ]] --[[ٽ]] --[[ٹ]]
    --[[ج]] 'arq', 'bcc',
      --[[ڃ]] --[[ڄ]] --[[چ]] --[[ڇ]] --[[ح]] --[[ځ]] --[[ڂ]] --[[څ]] --[[خ]]
    --[[د]] --[[ڋ]] --[[ڈ]] --[[ډ]] --[[ڊ]] --[[ڍ]] --[[ڎ]] --[[ڏ]] --[[ڐ]] --[[ذ]] --[[ڌ]]
    --[[ر]] 'bgn',
      --[[ڕ]] --[[ڒ]] --[[ڔ]] --[[ږ]] --[[ڗ]] --[[ڑ]] --[[ړ]] --[[ز]] --[[ڙ]] --[[ژ]]
    --[[س]] 'skr', 'skr-arab', 'sd',
      --[[ڛ]] --[[ښ]] --[[ڜ]]
      --[[ش]] 'ajp',
    --[[ص]] --[[ڝ]] --[[ڞ]] --[[ض]]
    --[[ط]] --[[ڟ]] --[[ظ]]
    --[[ع]] 'arb',
      --[[ڠ]] --[[غ]]
    --[[ڡ]]
      --[[ف]] 'fa-af', 'fa', 'prd',
      --[[ڢ]] --[[ڣ]] --[[ڤ]] --[[ڥ]] --[[ڦ]]
    --[[ق]] 'kk-arab', 'kk-cn',
      --[[ڧ]] --[[ڨ]]
    --[[ك]] 'ku-arab', 'kcn', 'kmr-arab',
      --[[ګ]] --[[ڮ]] --[[ڬ]] --[[ڭ]]
      --[[ک]] 'ks-arab', 'pbt', 'khw', 'ckb', 'sdh',
      --[[ڪ]]
      --[[گ]] 'glk',
      --[[ڰ]] --[[ڱ]] --[[ڳ]] --[[ڲ]] --[[ڴ]]
    --[[ل]] 'ota', 'lrc', 'luz', 'lki',
      --[[ڵ]] --[[ڶ]] --[[ڷ]]
    --[[م]] 'mve', 'mzn', 'arz', 'pst',
    --[[ں]] --[[ن]] --[[ڼ]] --[[ڻ]] --[[ڽ]]
    --[[ۃ]]
      --[[ه]] 'ha-arab',
      --[[ہ]] 'hno',
      --[[ھ]] --[[ۂ]] --[[ە]] --[[ۀ]]
    --[[و]] 'wne',
      --[[ۄ]] --[[ۆ]] --[[ۅ]] --[[ۇ]] --[[ۈ]] --[[ۉ]]
    --[[ې]] --[[ۍ]] --[[ى]] --[[ي]] --[[ێ]] --[[ۑ]] --[[ے]]
      --[[ی]] 'pbu',
      --[[ئ]] 'ug-arab', 'ug',
      --[[ۓ]]
  -- Other semitics abjads
    'arc', 'syc',
    'dv',
    'nqo',
    'phn', 'xpu',
-- Additional language codes that still need to be sorted by native name can be temporarily placed here
}

setmetatable(p, {
    quickTests = function()
        local s = {}
        for k, lang in pairs(p) do
            if type(k) ~= 'number' or k < 1 or k ~= math.floor(k)
            or type(lang) ~= 'string' or #lang < 2 or #lang > 16
            or (lang):find('^[a-z][%-0-9a-z]*[0-9a-z]$') ~= 1
            or s[lang] then
                return false, ': invalid sequence of distinct lowercase language codes at p[' .. tostring(k) .. '] = "' .. tostring(lang) .. '"'
            end
            s[lang] = true
        end
        return true
    end
})
--[[ To test this module in the Lua console: -- must return true
=getmetatable(p).quickTests()
--]]

return p