forked from quisquous/cactbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
languages.ts
74 lines (69 loc) · 1.36 KB
/
languages.ts
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
export const languages = ['en', 'de', 'fr', 'ja', 'cn', 'ko'] as const;
export type Lang = typeof languages[number];
export type NonEnLang = Exclude<Lang, 'en'>;
export const langMap: { [lang in Lang]: { [lang in Lang]: string } } = {
en: {
en: 'English',
de: 'German',
fr: 'French',
ja: 'Japanese',
cn: 'Chinese',
ko: 'Korean',
},
de: {
en: 'Englisch',
de: 'Deutsch',
fr: 'Französisch',
ja: 'Japanisch',
cn: 'Chinesisch',
ko: 'Koreanisch',
},
fr: {
en: 'Anglais',
de: 'Allemand',
fr: 'Français',
ja: 'Japonais',
cn: 'Chinois',
ko: 'Coréen',
},
ja: {
en: '英語',
de: 'ドイツ語',
fr: 'フランス語',
ja: '日本語',
cn: '中国語',
ko: '韓国語',
},
cn: {
en: '英语',
de: '德语',
fr: '法语',
ja: '日语',
cn: '中文',
ko: '韩语',
},
ko: {
en: '영어',
de: '독일어',
fr: '프랑스어',
ja: '일본어',
cn: '중국어',
ko: '한국어',
},
} as const;
export const isLang = (lang?: string): lang is Lang => {
const langStrs: readonly string[] = languages;
if (!lang)
return false;
return langStrs.includes(lang);
};
export const langToLocale = (lang: Lang): string => {
return {
en: 'en',
de: 'de',
fr: 'fr',
ja: 'ja',
cn: 'zh-CN',
ko: 'ko',
}[lang];
};