Module:Dir/RTL overrides/sandbox

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
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/sandbox, 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/sandbox.

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, as well as all 4-letters script codes
from ISO 15924  (that can be used in recognized suffixes) that have a predefined default direction, such that
it is excluding only special script codes ('-root', '-true', '-zinh', '-zxxx', '-zyyy', '-zzzz') and the range
of 50 script codes reserved for private use ('-qaaa', ..., '-qaaz', '-qaba', ..., '-qabx').

The list of supported ISO 15924 script codes below is complete up to the 2023-09-12 update (see
https://www.unicode.org/iso15924/codechanges.html).

Note that if a language+script variant uses another direction than the default for the script, it may still
be overridden explicitly (script subtags are checked only after checking full tags, so 'en-latn-rtl' could be
defined with a rtl direction, independantly of the default direction for '-latn', and some language-specific
variants for '-tfng' may also be defined as rtl instead of the default script direction).
--]==]
local rtlLangs = { '-adlm', '-arab', '-aran', '-armi', '-avst', '-chrs', '-elym', '-gara', '-hatr', '-hebr', '-hung', '-lydi', '-mand', '-mani', '-narb', '-nbat', '-nkoo', '-orkh', '-ougr', '-palm', '-pelm', '-phli', '-phlp', '-phlv', '-phnx', '-prti', '-psin', '-rohg', '-samr', '-sarb', '-sidt', '-sogd', '-sogo', '-syrc', '-syre', '-syrj', '-syrn', '-thaa', '-todr', '-yezi', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'adf', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'ar', 'arb', 'arc', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'azb', 'bal', 'bbz', 'bcc', 'bft', 'bgn', 'bgp', 'bjm', 'bqi', 'bsk', 'ckb', 'deh', 'dv', 'fa', 'fa-af', 'gda', 'glk', 'gwc', 'hac', 'hbo', 'he', 'hnd', 'hno', 'jat', 'kcn', 'kfr', 'khw', 'kk-cn', 'ktl', 'lah', 'lki', 'lrc', 'lrk', 'luz', 'mhj', 'mve', 'mvy', 'mzb', 'mzn', 'nqo', 'ota', 'pbt', 'pbu', 'pga', 'phl', 'phn', 'phr', 'phv', 'pnb', 'prd', 'prs', 'ps', 'pst', 'scl', 'sd', 'sdb', 'sdf', 'sdh', 'shu', 'skr', 'sqr', 'ssh', 'swh', 'syc', 'trw', 'ug', 'ur', 'uzs', 'wbl', 'wne', 'xhe', 'xpu', 'ydd', 'ydg', 'yi', 'yih' }

local ltrLangs = { '-afak', '-aghb', '-ahom', '-armn', '-bali', '-bamu', '-bass', '-batk', '-beng', '-bhks', '-blis', '-bopo', '-brah', '-brai', '-bugi', '-buhd', '-cakm', '-cans', '-cari', '-cham', '-cher', '-chis', '-cirt', '-copt', '-cpmn', '-cprt', '-cyrl', '-cyrs', '-deva', '-diak', '-dogr', '-dsrt', '-dupl', '-egyd', '-egyh', '-egyp', '-elba', '-ethi', '-geok', '-geor', '-glag', '-gong', '-gonm', '-goth', '-gran', '-grek', '-gujr', '-gukh', '-guru', '-hanb', '-hang', '-hani', '-hano', '-hans', '-hant', '-hira', '-hluw', '-hmng', '-hmnp', '-hrkt', '-inds', '-ital', '-jamo', '-java', '-jpan', '-jurc', '-kali', '-kana', '-kawi', '-khar', '-khmr', '-khoj', '-kitl', '-kits', '-knda', '-kore', '-kpel', '-krai', '-kthi', '-lana', '-laoo', '-latf', '-latg', '-latn', '-leke', '-lepc', '-limb', '-lina', '-linb', '-lisu', '-loma', '-lyci', '-mahj', '-maka', '-marc', '-maya', '-medf', '-mend', '-merc', '-mero', '-mlym', '-modi', '-mong', '-moon', '-mroo', '-mtei', '-mult', '-mymr', '-nagm', '-nand', '-newa', '-nkdb', '-nkgb', '-nshu', '-ogam', '-olck', '-onao', '-orya', '-osge', '-osma', '-pauc', '-pcun', '-perm', '-phag', '-piqd', '-plrd', '-ranj', '-rjng', '-roro', '-runr', '-sara', '-saur', '-sgnw', '-shaw', '-shrd', '-shui', '-sidd', '-sind', '-sinh', '-sora', '-soyo', '-sund', '-sunu', '-sylo', '-tagb', '-takr', '-tale', '-talu', '-taml', '-tang', '-tavt', '-tayo', '-telu', '-teng', '-tfng', '-tglg', '-thai', '-tibt', '-tirh', '-tnsa', '-tols', '-toto', '-tutg', '-ugar', '-vaii', '-visp', '-vith', '-wara', '-wcho', '-wole', '-xpeo', '-xsux', '-yiii', '-zanb', '-zmth', '-zsye', '-zsym', 'aa', 'aaq', 'ab', 'abe', 'abs', 'ace', 'acf', 'ady', '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', 'bar', 'bas', 'bat-smg', 'bax', 'bbc', 'bbj', 'bci', 'bcl', 'bdr', 'be', 'be-tarask', 'be-x-old', 'ber', 'bew', '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', 'chn', 'cho', 'chr', 'chy', 'cic', 'ciw', 'cku', 'cnh', 'co', 'coc', 'cok', 'cop', 'cps', 'cpx', 'cr', 'crh', 'crh-ro', 'crj', 'crk', 'crl', 'crm', 'cro', 'crs', 'cs', 'csb', 'csw', 'cu', 'cv', 'cwd', 'cy', 'da', 'dag', 'dak', 'de', 'de-at', 'de-ch', 'de-formal', 'dga', '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', 'gcf', 'gcr', 'gd', 'geh', 'gl', 'gld', 'gn', 'gom', 'gor', 'got', 'gpe', 'grc', 'grt', 'gsw', 'gu', 'guc', 'gur', 'guw', 'gv', 'gwi', 'gya', 'ha', 'hak', 'haw', 'hi', 'hid', 'hif', 'hil', 'hmn', 'hne', 'ho', 'hoc', 'hr', 'hrx', 'hsb', 'hsn', 'ht', 'hu', 'hu-formal', 'hy', 'hyw', 'hz', 'ia', 'ibb', 'id', 'ie', 'ig', 'igl', 'ii', 'ik', 'ikt', 'ilo', 'inh', 'io', 'is', 'isu', 'it', 'iu', 'ja', 'jam', 'jbo', 'jut', 'jv', 'ka', 'kaa', 'kab', 'kai', 'kbd', 'kbp', 'kcg', 'kea', 'ker', 'kg', 'kha', 'khn', 'ki', 'kiu', 'kj', 'kjh', 'kjp', 'kk', 'kk-kz', 'kk-tr', 'kl', 'km', 'kmb', 'kmr', 'kmw', 'kn', 'ko', 'ko-kp', 'ko-kr', 'koi', 'kr', 'krc', 'kri', 'krj', 'krl', 'kru', 'ks', 'ksf', 'ksh', 'ksw', 'ku', 'kum', 'kus', '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', 'mnc', 'mni', 'mnw', 'mo', 'moe', 'mos', 'mqm', 'mr', 'mrh', 'mrj', 'mrq', 'mrv', 'ms', 'mt', 'mtr', 'mua', 'mui', 'mus', 'mwl', 'mwr', 'my', 'myv', 'na', 'nah', 'nan', 'nap', 'nb', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'nge', 'nia', 'niu', 'njo', 'nl', 'nl-informal', 'nla', 'nmg', 'nmz', 'nn', 'nnh', 'nnz', 'no', 'nod', 'nog', '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', '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', 'rw', 'rwr', 'ryu', 'sa', 'sah', 'sak', 'sat', 'sc', 'scd', 'scn', 'sco', 'sdc', 'se', 'se-fi', 'se-no', 'se-se', 'sei', 'ses', 'sg', 'sgs', 'sh', 'shi', 'shn', 'shy', 'si', 'simple', 'sip', 'sjd', 'sje', 'sju', 'sk', 'sl', 'sli', 'sm', 'sma', 'smj', 'smn', 'sms', 'sn', 'so', 'sq', 'sr', 'sr-ec', 'sr-el', 'srn', 'sro', 'srq', 'ss', 'st', 'sto', 'stq', 'sty', 'su', 'suz', 'sv', 'sw', 'swb', 'swv', 'syl', 'szl', 'szy', 'ta', 'tay', 'tcy', 'tdd', 'te', 'tet', 'tg', 'th', 'thl', 'ti', 'tk', 'tl', 'tly', 'tn', 'to', 'tok', 'tokipona', 'tpi', 'tr', 'trp', 'tru', 'trv', 'ts', 'tt', 'tum', 'tun', 'tvu', 'tw', 'ty', 'tyv', 'tzl', 'tzm', 'udm', 'uk', 'umb', 'uve', 'uz', 've', 'vec', 'vep', 'vi', 'vic', 'vls', 'vmf', 'vmw', 'vo', 'vot', 'vro', 'vut', 'wa', 'wal', 'war', 'wes', 'win', 'wlc', 'wls', 'wni', 'wo', 'wry', 'wuu', 'wya', 'xac', 'xal', 'xh', 'xmf', 'xng', 'xnr', 'xpq', 'xsy', 'xtg', 'yas', 'yat', 'yav', 'ybb', 'yo', 'yrl', 'yue', 'za', 'zdj', 'zea', 'zgh', 'zh', 'zh-classical', 'zh-cn', '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