Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/i18n/const.ts
1447 views
1
/*
2
* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { defineMessage } from "react-intl";
7
8
import { IntlMessage } from "./types";
9
10
// ATTN: these languages have to match the frontend/package.json script "i18n:download",
11
// be valid for Antd (<AntdConfigProvider localize.../>),
12
// and also harmonize with localize::loadLocaleData
13
// They also have to match next.js, which is on-par with the languages.
14
export const LOCALE = [
15
"en", // that's the default, i.e. user never explicitly selected a language
16
"es",
17
"de",
18
"zh",
19
"ru",
20
"fr",
21
"it",
22
"nl",
23
"ja",
24
"hi",
25
"pt",
26
"ko",
27
"pl",
28
"tr",
29
"he",
30
"hu",
31
"ar",
32
] as const;
33
34
export type Locale = (typeof LOCALE)[number];
35
36
export function isLocale(val: unknown): val is Locale {
37
if (typeof val !== "string") return false;
38
return LOCALE.includes(val as any);
39
}
40
41
export const DEFAULT_LOCALE: Locale = "en";
42
43
// user's browser is not english, but user wants to keep english
44
// this is only for the account's other_settings and maps to "en"
45
export const KEEP_EN_LOCALE = "en-keep";
46
47
export const OTHER_SETTINGS_LOCALE_KEY = "i18n";
48
49
export const OTHER_SETTINGS_REPLY_ENGLISH_KEY = "llm_reply_english";
50
51
// The ordering is a bit "opinionated". The top languages are European ones, and German has the best quality translations.
52
// Then come other European languges, kind of alphabetical.
53
54
// Then, the Asian group starts with Chinese, as the largest group.
55
export const LOCALIZATIONS: {
56
[key in Locale]: {
57
name: string;
58
flag: string;
59
native: string;
60
trans: IntlMessage;
61
};
62
} = {
63
en: {
64
name: "English",
65
flag: "🇺🇸",
66
native: "English",
67
trans: defineMessage({
68
id: "i18n.localization.lang.english",
69
defaultMessage: "English",
70
}),
71
},
72
de: {
73
name: "German",
74
flag: "🇩🇪",
75
native: "Deutsch",
76
trans: defineMessage({
77
id: "i18n.localization.lang.german",
78
defaultMessage: "German",
79
}),
80
},
81
es: {
82
name: "Spanish",
83
flag: "🇪🇸",
84
native: "Español",
85
trans: defineMessage({
86
id: "i18n.localization.lang.spanish",
87
defaultMessage: "Spanish",
88
}),
89
},
90
fr: {
91
name: "French",
92
flag: "🇫🇷",
93
native: "Français",
94
trans: defineMessage({
95
id: "i18n.localization.lang.french",
96
defaultMessage: "French",
97
}),
98
},
99
it: {
100
name: "Italian",
101
flag: "🇮🇹",
102
native: "Italiano",
103
trans: defineMessage({
104
id: "i18n.localization.lang.italian",
105
defaultMessage: "Italian",
106
}),
107
},
108
nl: {
109
name: "Dutch",
110
flag: "🇳🇱",
111
native: "Nederlands",
112
trans: defineMessage({
113
id: "i18n.localization.lang.dutch",
114
defaultMessage: "Dutch",
115
}),
116
},
117
pl: {
118
name: "Polish",
119
flag: "🇵🇱",
120
native: "Polski",
121
trans: defineMessage({
122
id: "i18n.localization.lang.polish",
123
defaultMessage: "Polish",
124
}),
125
},
126
hu: {
127
name: "Hungarian",
128
flag: "🇭🇺",
129
native: "Magyar",
130
trans: defineMessage({
131
id: "i18n.localization.lang.hungarian",
132
defaultMessage: "Hungarian",
133
}),
134
},
135
ar: {
136
name: "Arabic",
137
flag: "🇪🇬",
138
native: "العربية",
139
trans: defineMessage({
140
id: "i18n.localization.lang.arabic",
141
defaultMessage: "Arabic",
142
}),
143
},
144
pt: {
145
name: "Portuguese",
146
flag: "🇵🇹",
147
native: "Português",
148
trans: defineMessage({
149
id: "i18n.localization.lang.portuguese",
150
defaultMessage: "Portuguese",
151
}),
152
},
153
tr: {
154
name: "Turkish",
155
flag: "🇹🇷",
156
native: "Türkçe",
157
trans: defineMessage({
158
id: "i18n.localization.lang.turkish",
159
defaultMessage: "Turkish",
160
}),
161
},
162
he: {
163
name: "Hebrew",
164
flag: "🇮🇱",
165
native: "עִבְרִית",
166
trans: defineMessage({
167
id: "i18n.localization.lang.hebrew",
168
defaultMessage: "Hebrew",
169
}),
170
},
171
zh: {
172
name: "Chinese",
173
flag: "🇨🇳",
174
native: "中文",
175
trans: defineMessage({
176
id: "i18n.localization.lang.chinese",
177
defaultMessage: "Chinese",
178
}),
179
},
180
ja: {
181
name: "Japanese",
182
flag: "🇯🇵",
183
native: "日本語",
184
trans: defineMessage({
185
id: "i18n.localization.lang.japanese",
186
defaultMessage: "Japanese",
187
}),
188
},
189
hi: {
190
name: "Hindi",
191
flag: "🇮🇳",
192
native: "हिन्दी",
193
trans: defineMessage({
194
id: "i18n.localization.lang.hindi",
195
defaultMessage: "Hindi",
196
}),
197
},
198
ko: {
199
name: "Korean",
200
flag: "🇰🇷",
201
native: "한국어",
202
trans: defineMessage({
203
id: "i18n.localization.lang.korean",
204
defaultMessage: "Korean",
205
}),
206
},
207
ru: {
208
name: "Russian",
209
flag: "🇷🇺",
210
native: "Русский",
211
trans: defineMessage({
212
id: "i18n.localization.lang.russian",
213
defaultMessage: "Russian",
214
}),
215
},
216
} as const;
217
218