Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/i18n/const.ts
5804 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", // european portuguese [pt_PT]
26
"ko",
27
"pl",
28
"tr",
29
"he",
30
"hu",
31
"ar",
32
"br", // brazilian portuguese [pt_BR]
33
"eu", // Basque [eu] (fallback: Catalan, Spanish)
34
] as const;
35
36
export type Locale = (typeof LOCALE)[number];
37
38
export function isLocale(val: unknown): val is Locale {
39
if (typeof val !== "string") return false;
40
return LOCALE.includes(val as any);
41
}
42
43
export const DEFAULT_LOCALE: Locale = "en";
44
45
// user's browser is not english, but user wants to keep english
46
// this is only for the account's other_settings and maps to "en"
47
export const KEEP_EN_LOCALE = "en-keep";
48
49
export const OTHER_SETTINGS_LOCALE_KEY = "i18n";
50
51
export const OTHER_SETTINGS_REPLY_ENGLISH_KEY = "llm_reply_english";
52
53
// The ordering is a bit "opinionated". The top languages are European ones, and German has the best quality translations.
54
// Then come other European languges, kind of alphabetical.
55
56
// Then, the Asian group starts with Chinese, as the largest group.
57
export const LOCALIZATIONS: {
58
[key in Locale]: {
59
name: string;
60
flag: string;
61
native: string;
62
trans: IntlMessage;
63
};
64
} = {
65
en: {
66
name: "English",
67
flag: "🇺🇸",
68
native: "English",
69
trans: defineMessage({
70
id: "i18n.localization.lang.english",
71
defaultMessage: "English",
72
description:
73
"The word for the langauge 'English', keep it as English but in the given target language.",
74
}),
75
},
76
de: {
77
name: "German",
78
flag: "🇩🇪",
79
native: "Deutsch",
80
trans: defineMessage({
81
id: "i18n.localization.lang.german",
82
defaultMessage: "German",
83
}),
84
},
85
es: {
86
name: "Spanish",
87
flag: "🇪🇸",
88
native: "Español",
89
trans: defineMessage({
90
id: "i18n.localization.lang.spanish",
91
defaultMessage: "Spanish",
92
}),
93
},
94
eu: {
95
name: "Basque",
96
flag: "🏴󠁥󠁳󠁰󠁶󠁿",
97
native: "Euskara",
98
trans: defineMessage({
99
id: "i18n.localization.lang.basque",
100
defaultMessage: "Basque",
101
}),
102
},
103
fr: {
104
name: "French",
105
flag: "🇫🇷",
106
native: "Français",
107
trans: defineMessage({
108
id: "i18n.localization.lang.french",
109
defaultMessage: "French",
110
}),
111
},
112
it: {
113
name: "Italian",
114
flag: "🇮🇹",
115
native: "Italiano",
116
trans: defineMessage({
117
id: "i18n.localization.lang.italian",
118
defaultMessage: "Italian",
119
}),
120
},
121
nl: {
122
name: "Dutch",
123
flag: "🇳🇱",
124
native: "Nederlands",
125
trans: defineMessage({
126
id: "i18n.localization.lang.dutch",
127
defaultMessage: "Dutch",
128
}),
129
},
130
pl: {
131
name: "Polish",
132
flag: "🇵🇱",
133
native: "Polski",
134
trans: defineMessage({
135
id: "i18n.localization.lang.polish",
136
defaultMessage: "Polish",
137
}),
138
},
139
hu: {
140
name: "Hungarian",
141
flag: "🇭🇺",
142
native: "Magyar",
143
trans: defineMessage({
144
id: "i18n.localization.lang.hungarian",
145
defaultMessage: "Hungarian",
146
}),
147
},
148
ar: {
149
name: "Arabic",
150
flag: "🇪🇬",
151
native: "العربية",
152
trans: defineMessage({
153
id: "i18n.localization.lang.arabic",
154
defaultMessage: "Arabic",
155
}),
156
},
157
br: {
158
name: "Portuguese (Br)",
159
flag: "🇧🇷",
160
native: "Português (Br)",
161
trans: defineMessage({
162
id: "i18n.localization.lang.portuguese.br",
163
defaultMessage: "Portuguese (Br)",
164
description:
165
"International Portuguese, Brazil. Keep the 'Br' abbrivation.",
166
}),
167
},
168
pt: {
169
name: "Portuguese (EU)",
170
flag: "🇵🇹",
171
native: "Português (EU)",
172
trans: defineMessage({
173
id: "i18n.localization.lang.portuguese.pt",
174
defaultMessage: "Portuguese (EU)",
175
description: "European Portuguese, Portugal.",
176
}),
177
},
178
tr: {
179
name: "Turkish",
180
flag: "🇹🇷",
181
native: "Türkçe",
182
trans: defineMessage({
183
id: "i18n.localization.lang.turkish",
184
defaultMessage: "Turkish",
185
}),
186
},
187
he: {
188
name: "Hebrew",
189
flag: "🇮🇱",
190
native: "עִבְרִית",
191
trans: defineMessage({
192
id: "i18n.localization.lang.hebrew",
193
defaultMessage: "Hebrew",
194
}),
195
},
196
zh: {
197
name: "Chinese",
198
flag: "🇨🇳",
199
native: "中文",
200
trans: defineMessage({
201
id: "i18n.localization.lang.chinese",
202
defaultMessage: "Chinese",
203
}),
204
},
205
ja: {
206
name: "Japanese",
207
flag: "🇯🇵",
208
native: "日本語",
209
trans: defineMessage({
210
id: "i18n.localization.lang.japanese",
211
defaultMessage: "Japanese",
212
}),
213
},
214
hi: {
215
name: "Hindi",
216
flag: "🇮🇳",
217
native: "हिन्दी",
218
trans: defineMessage({
219
id: "i18n.localization.lang.hindi",
220
defaultMessage: "Hindi",
221
}),
222
},
223
ko: {
224
name: "Korean",
225
flag: "🇰🇷",
226
native: "한국어",
227
trans: defineMessage({
228
id: "i18n.localization.lang.korean",
229
defaultMessage: "Korean",
230
}),
231
},
232
ru: {
233
name: "Russian",
234
flag: "🇷🇺",
235
native: "Русский",
236
trans: defineMessage({
237
id: "i18n.localization.lang.russian",
238
defaultMessage: "Russian",
239
}),
240
},
241
} as const;
242
243