aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-03-04 14:38:48 +0530
committersinanmohd <sinan@sinanmohd.com>2024-03-04 15:45:45 +0530
commitd6540310e4cd12cba67b0c2e6c666d94dd91f367 (patch)
treefb85a78451acf228f136e3de392e616679f1efd3 /lib
parent8982ec02694f925ebb311b386dcd06063e5e55fe (diff)
mpv: respect slang var
Diffstat (limited to 'lib')
-rw-r--r--lib/iso639.lua202
1 files changed, 202 insertions, 0 deletions
diff --git a/lib/iso639.lua b/lib/iso639.lua
new file mode 100644
index 0000000..6e853db
--- /dev/null
+++ b/lib/iso639.lua
@@ -0,0 +1,202 @@
+#!/usr/bin/env luajit
+
+local M = {}
+
+local map = {
+ ['ab'] = 'abk',
+ ['aa'] = 'aar',
+ ['af'] = 'afr',
+ ['ak'] = 'aka',
+ ['sq'] = 'sqi',
+ ['am'] = 'amh',
+ ['ar'] = 'ara',
+ ['an'] = 'arg',
+ ['hy'] = 'hye',
+ ['as'] = 'asm',
+ ['av'] = 'ava',
+ ['ae'] = 'ave',
+ ['ay'] = 'aym',
+ ['az'] = 'aze',
+ ['bm'] = 'bam',
+ ['ba'] = 'bak',
+ ['eu'] = 'eus',
+ ['be'] = 'bel',
+ ['bn'] = 'ben',
+ ['bi'] = 'bis',
+ ['bs'] = 'bos',
+ ['br'] = 'bre',
+ ['bg'] = 'bul',
+ ['my'] = 'mya',
+ ['ca'] = 'cat',
+ ['ch'] = 'cha',
+ ['ce'] = 'che',
+ ['ny'] = 'nya',
+ ['zh'] = 'zho',
+ ['cu'] = 'chu',
+ ['cv'] = 'chv',
+ ['kw'] = 'cor',
+ ['co'] = 'cos',
+ ['cr'] = 'cre',
+ ['hr'] = 'hrv',
+ ['cs'] = 'ces',
+ ['da'] = 'dan',
+ ['dv'] = 'div',
+ ['nl'] = 'nld',
+ ['dz'] = 'dzo',
+ ['en'] = 'eng',
+ ['eo'] = 'epo',
+ ['et'] = 'est',
+ ['ee'] = 'ewe',
+ ['fo'] = 'fao',
+ ['fj'] = 'fij',
+ ['fi'] = 'fin',
+ ['fr'] = 'fra',
+ ['fy'] = 'fry',
+ ['ff'] = 'ful',
+ ['gd'] = 'gla',
+ ['gl'] = 'glg',
+ ['lg'] = 'lug',
+ ['ka'] = 'kat',
+ ['de'] = 'deu',
+ ['el'] = 'ell',
+ ['kl'] = 'kal',
+ ['gn'] = 'grn',
+ ['gu'] = 'guj',
+ ['ht'] = 'hat',
+ ['ha'] = 'hau',
+ ['he'] = 'heb',
+ ['hz'] = 'her',
+ ['hi'] = 'hin',
+ ['ho'] = 'hmo',
+ ['hu'] = 'hun',
+ ['is'] = 'isl',
+ ['io'] = 'ido',
+ ['ig'] = 'ibo',
+ ['id'] = 'ind',
+ ['ia'] = 'ina',
+ ['ie'] = 'ile',
+ ['iu'] = 'iku',
+ ['ik'] = 'ipk',
+ ['ga'] = 'gle',
+ ['it'] = 'ita',
+ ['ja'] = 'jpn',
+ ['jv'] = 'jav',
+ ['kn'] = 'kan',
+ ['kr'] = 'kau',
+ ['ks'] = 'kas',
+ ['kk'] = 'kaz',
+ ['km'] = 'khm',
+ ['ki'] = 'kik',
+ ['rw'] = 'kin',
+ ['ky'] = 'kir',
+ ['kv'] = 'kom',
+ ['kg'] = 'kon',
+ ['ko'] = 'kor',
+ ['kj'] = 'kua',
+ ['ku'] = 'kur',
+ ['lo'] = 'lao',
+ ['la'] = 'lat',
+ ['lv'] = 'lav',
+ ['li'] = 'lim',
+ ['ln'] = 'lin',
+ ['lt'] = 'lit',
+ ['lu'] = 'lub',
+ ['lb'] = 'ltz',
+ ['mk'] = 'mkd',
+ ['mg'] = 'mlg',
+ ['ms'] = 'msa',
+ ['ml'] = 'mal',
+ ['mt'] = 'mlt',
+ ['gv'] = 'glv',
+ ['mi'] = 'mri',
+ ['mr'] = 'mar',
+ ['mh'] = 'mah',
+ ['mn'] = 'mon',
+ ['na'] = 'nau',
+ ['nv'] = 'nav',
+ ['nd'] = 'nde',
+ ['nr'] = 'nbl',
+ ['ng'] = 'ndo',
+ ['ne'] = 'nep',
+ ['no'] = 'nor',
+ ['nb'] = 'nob',
+ ['nn'] = 'nno',
+ ['ii'] = 'iii',
+ ['oc'] = 'oci',
+ ['oj'] = 'oji',
+ ['or'] = 'ori',
+ ['om'] = 'orm',
+ ['os'] = 'oss',
+ ['pi'] = 'pli',
+ ['ps'] = 'pus',
+ ['fa'] = 'fas',
+ ['pl'] = 'pol',
+ ['pt'] = 'por',
+ ['pa'] = 'pan',
+ ['qu'] = 'que',
+ ['ro'] = 'ron',
+ ['rm'] = 'roh',
+ ['rn'] = 'run',
+ ['ru'] = 'rus',
+ ['se'] = 'sme',
+ ['sm'] = 'smo',
+ ['sg'] = 'sag',
+ ['sa'] = 'san',
+ ['sc'] = 'srd',
+ ['sr'] = 'srp',
+ ['sn'] = 'sna',
+ ['sd'] = 'snd',
+ ['si'] = 'sin',
+ ['sk'] = 'slk',
+ ['sl'] = 'slv',
+ ['so'] = 'som',
+ ['st'] = 'sot',
+ ['es'] = 'spa',
+ ['su'] = 'sun',
+ ['sw'] = 'swa',
+ ['ss'] = 'ssw',
+ ['sv'] = 'swe',
+ ['tl'] = 'tgl',
+ ['ty'] = 'tah',
+ ['tg'] = 'tgk',
+ ['ta'] = 'tam',
+ ['tt'] = 'tat',
+ ['te'] = 'tel',
+ ['th'] = 'tha',
+ ['bo'] = 'bod',
+ ['ti'] = 'tir',
+ ['to'] = 'ton',
+ ['ts'] = 'tso',
+ ['tn'] = 'tsn',
+ ['tr'] = 'tur',
+ ['tk'] = 'tuk',
+ ['tw'] = 'twi',
+ ['ug'] = 'uig',
+ ['uk'] = 'ukr',
+ ['ur'] = 'urd',
+ ['uz'] = 'uzb',
+ ['ve'] = 'ven',
+ ['vi'] = 'vie',
+ ['vo'] = 'vol',
+ ['wa'] = 'wln',
+ ['cy'] = 'cym',
+ ['wo'] = 'wol',
+ ['xh'] = 'xho',
+ ['yi'] = 'yid',
+ ['yo'] = 'yor',
+ ['za'] = 'zha',
+ ['zu'] = 'zul',
+}
+
+M.toset2 = function(iso639_lang)
+ if iso639_lang:len() == 2 then
+ -- convert to set1 to set2
+ return map[iso639_lang]
+ elseif iso639_lang:len() == 3 then
+ -- retun as it is if arg is already set 2.
+ -- we blindly trust it's valid if there's 3 chars
+ return iso639_lang
+ end
+end
+
+return M