Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

  • For testing the coherence and completeness of the language lists, look at the status shown in the base page of this Module:Dir, where you can run =getmetatable(p).quickTests() in the Lua console to see a detailed analysis.
  • For seeing the complete list of languages, tested with their directionality defined here, look at the tests results table on Module talk:Multilingual description/sort/testcases.

Code

local p = {}

--[==[
Basic input sequences: relative order or duplicates does not matter here (but the end of the self test displays them sorted and deduplicated),
but codes must be valid and belong to only one of the two sequences).

Any missing language code will be checked with mw.language.new(code):isRTL(), which is costly
in loaded resources (it can only check 20 languages at most including the content language)
So it is best to map all languages that are the most likely to be used.
--]==]

local rtlLangs = { 'aaf-arab', 'aao', 'abh', 'abq-arab', 'abv', 'ace-arab', 'acm', 'acq', 'acw', 'acx', 'acy-arab', 'adf', 'ady-arab', 'aeb', 'aeb-arab', 'aec', 'afb', 'ajp', 'apc', 'apd', 'ar', 'arb', 'arc', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'az-arab', 'azb', 'bal', 'bbz', 'bcc', 'bej-arab', 'ber-arab', 'bft', 'bgn', 'bgp', 'bqi', 'bjm', 'bjn-arab', 'bms-arab', 'brh-arab', 'bsk', 'cja-arab', 'cjm-arab', 'ckb', 'crh-arab', 'deh', 'dgo-arab', 'dng-arab', 'doi-arab', 'dv', 'dyu-arab', 'fa', 'fa-af', 'ff-arab', 'ffm-arab', 'fub-arab', 'fuc-arab', 'fuf-arab', 'fuh-arab', 'fui-arab', 'fuv-arab', 'gda', 'glk', 'gwc', 'gbz-arab', 'gju-arab', 'ha-arab', 'hac', 'he', 'hnd', 'hno', 'jat', 'kbd-arab', 'kbl-arab', 'kby-arab', 'kcn', 'kfr', 'khw', 'kk-arab', 'kk-cn', 'kls-arab', 'kmr-arab', 'knc-arab', 'kr-arab', 'krt-arab', 'ks-arab', 'ktl', 'ku-arab', 'ky-arab', 'lah', 'lki', 'lrc', 'lrk', 'luz', 'mad-arab', 'man-arab', 'mge-arab', 'mhj', 'mki-arab', 'mne-arab', 'mnk-arab', 'mrt-arab', 'ms-arab', 'mve', 'mvy', 'mwr-arab', 'mzb', 'mzn', 'nqo', 'ota', 'pa-arab', 'pga', 'pbt', 'pbu', 'phl', 'phn', 'phr', 'phv', 'pnb', 'prd', 'prs', 'ps', 'pst', 'raj-arab', 'rif-arab', 'rmt-arab', 'scl', 'sd', 'sdb', 'sdf', 'sdh', 'shi-arab', 'shu', 'shy-arab', 'skr', 'skr-arab', 'sqr', 'ssh', 'su-arab', 'sw-arab', 'swh', 'tg-arab', 'tig-arab', 'tk-arab', 'tly-arab', 'tt-arab', 'trw', 'txj-arab', 'ug', 'ug-arab', 'ur', 'uz-arab', 'uzs', 'wbl', 'wlc-arab', 'wne', 'wni-arab', 'wo-arab', 'xhe', 'xng-arab', 'xpu', 'ydd', 'ydg', 'yhd-arab', 'yi', 'yih', 'zdj-arab' }

local ltrLangs = { 'aa', 'aaq', 'ab', 'abe', 'abs', 'ace', 'acf', 'ady', 'ady-cyrl', 'aeb-latn', 'af', 'agq', 'ak', 'akz', 'ale', 'aln', 'alq', 'als', 'alt', 'am', 'ami', 'an', 'ang', 'ann', 'anp', 'arn', 'as', 'asb', 'ase', 'ast', 'atj', 'aut', 'av', 'avk', 'awa', 'ay', 'az', 'azj', 'ba', 'bag', 'ban', 'ban-bali', 'bar', 'bas', 'bat-smg', 'bax', 'bbc', 'bbc-latn', 'bbj', 'bci', 'bcl', 'be', 'be-tarask', 'be-x-old', 'ber', 'bfd', 'bg', 'bh', 'bho', 'bi', 'bjn', 'bkc', 'bkh', 'bkm', 'blc', 'blk', 'bm', 'bn', 'bnm', 'bo', 'bpy', 'bqz', 'br', 'brh', 'brx', 'bs', 'btm', 'bto', 'bu', 'buc', 'bug', 'bxr', 'byv', 'bzj', 'ca', 'cak', 'cbk-zam', 'ccp', 'cdo', 'ce', 'ceb', 'ch', 'chc', 'cho', 'chr', 'chy', 'cic', 'ciw', 'cku', 'cnh', 'co', 'coc', 'cok', 'cop', 'cps', 'cr', 'crh', 'crh-cyrl', 'crh-latn', 'crj', 'crk', 'crl', 'crm', 'cro', 'crs', 'cs', 'csb', 'csw', 'cu', 'cv', 'cwd', 'cy', 'da', 'dag', 'dak', 'de', 'de-at', 'de-ch', 'de-formal', 'dgo', 'dhd', 'din', 'diq', 'doi', 'dsb', 'dtp', 'dty', 'dua', 'dum', 'dz', 'ee', 'egl', 'el', 'eml', 'en', 'en-ca', 'en-gb', 'en-ie', 'en-us', 'eo', 'es', 'es-419', 'es-formal', 'esu', 'et', 'eto', 'etu', 'eu', 'ewo', 'ext', 'fak', 'fan', 'fat', 'ff', 'fi', 'fil', 'fit', 'fiu-vro', 'fj', 'fkv', 'fmp', 'fo', 'fon', 'fr', 'frc', 'frm', 'fro', 'frp', 'frr', 'fub', 'fuc', 'fud', 'fue', 'fuf', 'fuh', 'fui', 'fur', 'fuv', 'fy', 'ga', 'gaa', 'gag', 'gan', 'gan-hans', 'gan-hant', 'gcf', 'gcr', 'gd', 'geh', 'gl', 'gld', 'gn', 'gom', 'gom-deva', 'gom-latn', 'gor', 'got', 'gpe', 'grc', 'grt', 'gsw', 'gu', 'guc', 'gur', 'guw', 'gv', 'gwi', 'gya', 'ha', 'hak', 'haw', 'hi', 'hid', 'hif', 'hif-deva', 'hif-latn', 'hil', 'hmn', 'hne', 'ho', 'hoc', 'hr', 'hrx', 'hsb', 'hsn', 'ht', 'hu', 'hu-formal', 'hy', 'hyw', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'ike-cans', 'ike-latn', 'ikt', 'ilo', 'inh', 'io', 'is', 'isu', 'it', 'iu', 'ja', 'jam', 'jbo', 'jut', 'jv', 'ka', 'kaa', 'kab', 'kbd', 'kbd-cyrl', 'kbd-latn', 'kbp', 'kcg', 'kea', 'ker', 'kg', 'kha', 'khn', 'ki', 'kiu', 'kj', 'kjp', 'kk', 'kk-cyrl', 'kk-kz', 'kk-latn', 'kk-tr', 'kl', 'km', 'kmb', 'kmr', 'kmr-cyrl', 'kmr-latn', 'kmw', 'kn', 'ko', 'ko-kp', 'ko-kr', 'koi', 'kr', 'krc', 'kri', 'krj', 'krl', 'kru', 'ks', 'ks-deva', 'ksf', 'ksh', 'ksw', 'ku', 'ku-latn', 'kum', 'kv', 'kw', 'ky', 'la', 'lad', 'lb', 'lbe', 'lem', 'lep', 'lez', 'lfn', 'lg', 'li', 'lif', 'lij', 'liv', 'lkt', 'lld', 'lmo', 'ln', 'lns', 'lo', 'loz', 'lt', 'ltg', 'lu', 'lus', 'lv', 'lzh', 'lzz', 'mad', 'mag', 'mai', 'map-bms', 'mcn', 'mcp', 'mdf', 'mfe', 'mg', 'mgp', 'mh', 'mhr', 'mhv', 'mi', 'mic', 'mik', 'min', 'mk', 'ml', 'mn', 'mni', 'mnw', 'mo', 'moe', 'mos', 'mqm', 'mr', 'mrh', 'mrj', 'mrq', 'mrv', 'ms', 'mt', 'mtr', 'mua', 'mus', 'mwl', 'mwr', 'my', 'myv', 'na', 'nah', 'nan', 'nan-hani', 'nap', 'nb', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'nge', 'nia', 'niu', 'njo', 'nl', 'nl-informal', 'nla', 'nmg', 'nmz', 'nn', 'nnh', 'nnz', 'no', 'nod', 'non', 'nov', 'nrf', 'nrf-fr', 'nrf-gg', 'nrf-je', 'nrm', 'nsk', 'nso', 'nv', 'ny', 'nyn', 'nys', 'oc', 'ojb', 'ojc', 'ojg', 'ojs', 'ojw', 'oka', 'olo', 'om', 'oma', 'or', 'os', 'osa', 'osa-latn', 'otw', 'pa', 'pag', 'pam', 'pap', 'pap-aw', 'pcd', 'pcm', 'pdc', 'pdt', 'pfl', 'pi', 'pih', 'pl', 'pms', 'pmt', 'pnt', 'prg', 'pt', 'pt-br', 'pt-cv', 'pt-pt', 'pwn', 'qu', 'quc', 'qug', 'ray', 'rcf', 'rgn', 'rif', 'rki', 'rkt', 'rm', 'rmc', 'rme', 'rmf', 'rmo', 'rmq', 'rmy', 'rmz', 'rn', 'ro', 'roa-rup', 'roa-tara', 'rsk', 'ru', 'rue', 'rup', 'ruq', 'ruq-cyrl', 'ruq-latn', 'rw', 'rwr', 'ryu', 'sa', 'sah', 'sak', 'sat', 'sc', 'scd', 'scn', 'sco', 'sdc', 'se', 'se-fi', 'se-no', 'se-se', 'sei', 'ses', 'sg', 'sgs', 'sh', 'sh-cyrl', 'sh-latn', 'shi', 'shi-latn', 'shi-tfng', 'shn', 'shy', 'shy-latn', 'si', 'simple', 'sip', 'sjd', 'sje', 'sju', 'sk', 'sl', 'sli', 'sm', 'sma', 'smj', 'smn', 'sms', 'sn', 'so', 'sq', 'sr', 'sr-cyrl', 'sr-ec', 'sr-el', 'sr-latn', 'srn', 'sro', 'srq', 'ss', 'st', 'sto', 'stq', 'sty', 'su', 'suz', 'sv', 'sw', 'swb', 'swv', 'syl', 'szl', 'szy', 'ta', 'tay', 'tcy', 'tdd', 'te', 'tet', 'tg', 'tg-cyrl', 'tg-latn', 'th', 'thl', 'ti', 'tk', 'tl', 'tly', 'tly-cyrl', 'tn', 'to', 'tokipona', 'tpi', 'tr', 'trp', 'tru', 'trv', 'ts', 'tt', 'tt-cyrl', 'tt-latn', 'tum', 'tun', 'tvu', 'tw', 'ty', 'tyv', 'tzl', 'tzm', 'udm', 'ug-latn', 'uk', 'umb', 'uve', 'uz', 'uz-cyrl', 'uz-latn', 've', 'vec', 'vep', 'vi', 'vic', 'vls', 'vmf', 'vmw', 'vo', 'vot', 'vro', 'vut', 'wa', 'war', 'wes', 'win', 'wlc', 'wls', 'wni', 'wo', 'wry', 'wuu', 'wya', 'xac', 'xal', 'xh', 'xmf', 'xnr', 'xpq', 'xsy', 'xtg', 'yas', 'yat', 'yav', 'ybb', 'yo', 'yrl', 'yue', 'za', 'zdj', 'zea', 'zgh', 'zh', 'zh-classical', 'zh-cn', 'zh-hans', 'zh-hant', 'zh-hk', 'zh-min-nan', 'zh-mo', 'zh-my', 'zh-sg', 'zh-tw', 'zh-wuu', 'zh-yue', 'zu', 'zun' }

-- Build the inverted map of languages to direction returned by this data module (fast, but collisions are not checked: run the test module).
for _, lang in ipairs(rtlLangs) do p[lang] = true end
for _, lang in ipairs(ltrLangs) do p[lang] = false end

-- Also store the two lists (at boolean indice), used by the test module to check the inverted map.
p[true] = rtlLangs
p[false] = ltrLangs

return p