@@ -9,8 +9,9 @@ Jupyter notebook server is running, then pops it up in a new tab.
9
9
*/
10
10
11
11
import { join } from "path" ;
12
- import React from "react" ;
12
+ import { defineMessage , FormattedMessage , useIntl } from "react-intl " ;
13
13
14
+ import { CSS } from "@cocalc/frontend/app-framework" ;
14
15
import {
15
16
Icon ,
16
17
IconName ,
@@ -20,16 +21,23 @@ import {
20
21
import LinkRetry from "@cocalc/frontend/components/link-retry" ;
21
22
import { useStudentProjectFunctionality } from "@cocalc/frontend/course" ;
22
23
import { appBasePath } from "@cocalc/frontend/customize/app-base-path" ;
24
+ import { IntlMessage } from "@cocalc/frontend/i18n" ;
23
25
import track from "@cocalc/frontend/user-tracking" ;
24
26
import { R_IDE } from "@cocalc/util/consts/ui" ;
25
27
import { capitalize } from "@cocalc/util/misc" ;
26
28
import { COLORS } from "@cocalc/util/theme" ;
27
29
import { NamedServerName } from "@cocalc/util/types/servers" ;
28
30
import { useAvailableFeatures } from "./use-available-features" ;
29
31
32
+ const LAUNCHING_SERVER = defineMessage ( {
33
+ id : "project.named-server-panel.launching_server" ,
34
+ defaultMessage : "Launching server..." ,
35
+ description : "A web-service is starting." ,
36
+ } ) ;
37
+
30
38
interface Server {
31
39
longName : string ;
32
- description : React . ReactNode ;
40
+ description : IntlMessage ;
33
41
usesBasePath : boolean ;
34
42
icon : IconName ;
35
43
}
@@ -39,46 +47,59 @@ export const SPEC: {
39
47
} = {
40
48
jupyter : {
41
49
longName : "Jupyter Classic Notebook" ,
42
- description : `The Jupyter Classic notebook server runs in your project and provides
43
- support for classical Jupyter notebooks. You can also use the plain
44
- classical Jupyter notebook server directly via the link below. This
45
- does not support multiple users or TimeTravel, but fully supports all
46
- classical Jupyter notebook features and extensions.` ,
50
+ description : defineMessage ( {
51
+ id : "project.named-server-panel.spec.jupyter.description" ,
52
+ defaultMessage : `The Jupyter Classic notebook server runs in your project and provides
53
+ support for classical Jupyter notebooks.
54
+ You can also use the plain classical Jupyter notebook server directly via the link below.
55
+ This does not support multiple users or TimeTravel,
56
+ but fully supports all classical Jupyter notebook features and extensions.` ,
57
+ } ) ,
47
58
usesBasePath : true ,
48
59
icon : "ipynb" ,
49
60
} ,
50
61
jupyterlab : {
51
62
longName : "JupyterLab Notebook" ,
52
- description : `The JupyterLab server runs from your project and provides support for
53
- Jupyter notebooks, terminals, drag and drop, with a nice multiwindow
54
- layout, and much more. JupyterLab does not yet support multiple users
55
- or TimeTravel, but fully supports most Jupyter notebook features and
56
- extensions.` ,
63
+ description : defineMessage ( {
64
+ id : "project.named-server-panel.spec.jupyterlab.description" ,
65
+ defaultMessage : `The JupyterLab server runs from your project and provides support for Jupyter notebooks,
66
+ terminals, drag and drop, with a nice multiwindow layout, and much more.
67
+ JupyterLab does not yet support multiple users or TimeTravel,
68
+ but fully supports most Jupyter notebook features and extensions.` ,
69
+ } ) ,
57
70
usesBasePath : true ,
58
71
icon : "ipynb" ,
59
72
} ,
60
73
code : {
61
74
longName : "Visual Studio Code" ,
62
- description : `Visual Studio Code is a source-code editor made by Microsoft. Features
63
- include support for debugging, syntax highlighting, intelligent
64
- code completion, snippets, code refactoring, and embedded Git.` ,
75
+ description : defineMessage ( {
76
+ id : "project.named-server-panel.spec.code.description" ,
77
+ defaultMessage : `Visual Studio Code is a source-code editor made by Microsoft.
78
+ Features include support for debugging, syntax highlighting,
79
+ intelligent code completion, snippets, code refactoring, and embedded Git.` ,
80
+ } ) ,
65
81
usesBasePath : false ,
66
82
icon : "vscode" ,
67
83
} ,
68
84
pluto : {
69
85
longName : "Julia Pluto.jl" ,
70
- description : (
71
- < >
72
- Reactive notebooks for Julia.{ " " }
73
- < b > NOTE: Pluto may take a long time to start, so be patient.</ b >
74
- </ >
75
- ) ,
86
+ description : defineMessage ( {
87
+ id : "project.named-server-panel.spec.pluto.description" ,
88
+ defaultMessage : ` Reactive notebooks for Julia.
89
+ <b>NOTE: Pluto may take a long time to start, so be patient.</b> ` ,
90
+ } ) ,
91
+
76
92
usesBasePath : false ,
77
93
icon : "julia" ,
78
94
} ,
79
95
rserver : {
80
96
longName : R_IDE ,
81
- description : `This is an integrated development environment (IDE) for R, sometimes called "R Studio". It is provided without any modifications. DISCLAIMER: Posit Software, PBC (formerly RStudio, PBC) IS IN NO WAY ASSOCIATED WITH COCALC.` ,
97
+ description : defineMessage ( {
98
+ id : "project.named-server-panel.spec.rserver.description" ,
99
+ defaultMessage : `This is an integrated development environment (IDE) for R, sometimes called "R Studio".
100
+ It is provided without any modifications.
101
+ <b>DISCLAIMER: Posit Software, PBC (formerly RStudio, PBC) IS IN NO WAY ASSOCIATED WITH COCALC.</b>` ,
102
+ } ) ,
82
103
usesBasePath : false ,
83
104
icon : "r" ,
84
105
} ,
@@ -89,66 +110,76 @@ function getServerInfo(name: NamedServerName): Server {
89
110
SPEC [ name ] ?? {
90
111
icon : "server" ,
91
112
longName : `${ capitalize ( name ) } Server` ,
92
- description : `The ${ capitalize (
93
- name ,
94
- ) } server runs from your project. It does not yet
95
- support multiple users or TimeTravel, but fully supports most other
96
- features and extensions of ${ name } .` ,
113
+ description : defineMessage ( {
114
+ id : "project.named-server-panel.spec.server.description" ,
115
+ defaultMessage : `The {name} server runs from your project.
116
+ It does not yet support multiple users or TimeTravel,
117
+ but fully supports most other features and extensions of {name}.` ,
118
+ } ) ,
97
119
}
98
120
) ;
99
121
}
100
122
123
+ const DISABLED = defineMessage ( {
124
+ id : "project.named-server-panel.disabled.info" ,
125
+ defaultMessage : `"Disabled. Please contact your instructor if you need to use {longName}.` ,
126
+ } ) ;
127
+
101
128
interface Props {
102
129
project_id : string ;
103
130
name : NamedServerName ;
104
- style ?;
131
+ style ?: CSS ;
105
132
}
106
133
107
134
export function NamedServerPanel ( { project_id, name, style } : Props ) {
135
+ const intl = useIntl ( ) ;
136
+
108
137
const student_project_functionality =
109
138
useStudentProjectFunctionality ( project_id ) ;
110
139
111
- const { longName, description, icon } = getServerInfo ( name ) ;
140
+ const { longName, description : descMsg , icon } = getServerInfo ( name ) ;
141
+ const description = intl . formatMessage ( descMsg , { name : capitalize ( name ) } ) ;
112
142
113
143
let body ;
114
144
if (
115
145
name === "jupyterlab" &&
116
146
student_project_functionality . disableJupyterLabServer
117
147
) {
118
- body =
119
- "Disabled. Please contact your instructor if you need to use Jupyter Lab" ;
148
+ body = intl . formatMessage ( DISABLED , { longName } ) ;
120
149
} else if (
121
150
name === "jupyter" &&
122
151
student_project_functionality . disableJupyterClassicServer
123
152
) {
124
- body =
125
- "Disabled. Please contact your instructor if you need to use Jupyter Classic." ;
153
+ body = intl . formatMessage ( DISABLED , { longName } ) ;
126
154
} else if (
127
155
name === "code" &&
128
156
student_project_functionality . disableVSCodeServer
129
157
) {
130
- body =
131
- "Disabled. Please contact your instructor if you need to use VS Code." ;
158
+ body = intl . formatMessage ( DISABLED , { longName } ) ;
132
159
} else if (
133
160
name === "pluto" &&
134
161
student_project_functionality . disablePlutoServer
135
162
) {
136
- body = "Disabled. Please contact your instructor if you need to use Pluto." ;
163
+ body = intl . formatMessage ( DISABLED , { longName } ) ;
137
164
} else if (
138
165
name === "rserver" &&
139
166
student_project_functionality . disableRServer
140
167
) {
141
- body =
142
- "Disabled. Please contact your instructor if you need to use RStudio." ;
168
+ body = intl . formatMessage ( DISABLED , { longName } ) ;
143
169
} else {
144
170
body = (
145
171
< >
146
172
< Paragraph style = { { color : COLORS . GRAY_D } } >
147
173
{ description }
148
174
< br />
149
175
< br />
150
- Starting your { longName } server. It will then attempt to open in a new
151
- browser tab. If this doesn't work, check for a popup blocker warning!
176
+ < FormattedMessage
177
+ id = "project.named-server-panel.long_start_info"
178
+ defaultMessage = { `Starting your {longName} server.
179
+ It will then attempt to open in a new browser tab.
180
+ If this doesn't work, check for a popup blocker warning!` }
181
+ values = { { longName } }
182
+ />
152
183
</ Paragraph >
153
184
< Paragraph
154
185
style = { { textAlign : "center" , fontSize : "14pt" , margin : "15px" } }
@@ -157,7 +188,7 @@ export function NamedServerPanel({ project_id, name, style }: Props) {
157
188
maxTime = { 1000 * 60 * 5 }
158
189
autoStart
159
190
href = { serverURL ( project_id , name ) }
160
- loadingText = "Launching server..."
191
+ loadingText = { intl . formatMessage ( LAUNCHING_SERVER ) }
161
192
onClick = { ( ) => {
162
193
track ( "launch-server" , { name, project_id } ) ;
163
194
} }
@@ -196,6 +227,7 @@ export function ServerLink({
196
227
name : NamedServerName ;
197
228
mode : "flyout" | "full" ;
198
229
} ) {
230
+ const intl = useIntl ( ) ;
199
231
const student_project_functionality =
200
232
useStudentProjectFunctionality ( project_id ) ;
201
233
const available = useAvailableFeatures ( project_id ) ;
@@ -227,12 +259,13 @@ export function ServerLink({
227
259
) {
228
260
return null ;
229
261
} else {
230
- const { icon, longName, description } = getServerInfo ( name ) ;
262
+ const { icon, longName, description : descMsg } = getServerInfo ( name ) ;
263
+ const description = intl . formatMessage ( descMsg , { name : capitalize ( name ) } ) ;
231
264
return (
232
265
< LinkRetry
233
266
maxTime = { 1000 * 60 * 5 }
234
267
href = { serverURL ( project_id , name ) }
235
- loadingText = "Launching server..."
268
+ loadingText = { intl . formatMessage ( LAUNCHING_SERVER ) }
236
269
tooltip = { mode === "flyout" ? description : undefined }
237
270
onClick = { ( ) => {
238
271
track ( "launch-server" , { name, project_id } ) ;
0 commit comments