-
Notifications
You must be signed in to change notification settings - Fork 65
/
languages.js
76 lines (72 loc) · 2.13 KB
/
languages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const languageMapping = {
'dubbed': 'Dubbed',
'multi audio': 'Multi Audio',
'multi subs': 'Multi Subs',
'dual audio': 'Dual Audio',
'english': '🇬🇧',
'japanese': '🇯🇵',
'russian': '🇷🇺',
'italian': '🇮🇹',
'portuguese': '🇵🇹',
'spanish': '🇪🇸',
'latino': '🇲🇽',
'korean': '🇰🇷',
'chinese': '🇨🇳',
'taiwanese': '🇹🇼',
'french': '🇫🇷',
'german': '🇩🇪',
'dutch': '🇳🇱',
'hindi': '🇮🇳',
'telugu': '🇮🇳',
'tamil': '🇮🇳',
'polish': '🇵🇱',
'lithuanian': '🇱🇹',
'latvian': '🇱🇻',
'estonian': '🇪🇪',
'czech': '🇨🇿',
'slovakian': '🇸🇰',
'slovenian': '🇸🇮',
'hungarian': '🇭🇺',
'romanian': '🇷🇴',
'bulgarian': '🇧🇬',
'serbian': '🇷🇸 ',
'croatian': '🇭🇷',
'ukrainian': '🇺🇦',
'greek': '🇬🇷',
'danish': '🇩🇰',
'finnish': '🇫🇮',
'swedish': '🇸🇪',
'norwegian': '🇳🇴',
'turkish': '🇹🇷',
'arabic': '🇸🇦',
'persian': '🇮🇷',
'hebrew': '🇮🇱',
'vietnamese': '🇻🇳',
'indonesian': '🇮🇩',
'malay': '🇲🇾',
'thai': '🇹🇭'
}
export const LanguageOptions = {
key: 'language',
options: Object.keys(languageMapping).slice(5).map(lang => ({
key: lang,
label: `${languageMapping[lang]} ${lang.charAt(0).toUpperCase()}${lang.slice(1)}`
}))
}
export function mapLanguages(languages) {
const mapped = languages
.map(language => languageMapping[language])
.filter(language => language)
.sort((a, b) => Object.values(languageMapping).indexOf(a) - Object.values(languageMapping).indexOf(b));
const unmapped = languages
.filter(language => !languageMapping[language])
.sort((a, b) => a.localeCompare(b))
return [...new Set([].concat(mapped).concat(unmapped))];
}
export function containsLanguage(stream, languages) {
return languages.map(lang => languageMapping[lang]).some(lang => stream.title.includes(lang));
}
export function languageFromCode(code) {
const entry = Object.entries(languageMapping).find(entry => entry[1] === code);
return entry?.[0];
}