Skip to content

Commit 493e6cd

Browse files
authored
Merge pull request #7975 from sagemathinc/i18n-20241022
i18n 2024-10-22
2 parents 40d3619 + 1f7f6c9 commit 493e6cd

37 files changed

+766
-187
lines changed

src/packages/frontend/account/licenses/projects-with-licenses.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Alert, Row, Col } from "antd";
6+
import { Alert, Col, Row } from "antd";
77
import { useEffect, useMemo, useState } from "react";
8-
import { useTypedRedux, redux } from "../../app-framework";
9-
import { Loading, TimeAgo } from "../../components";
10-
import { projects_with_licenses } from "./util";
11-
import { plural, trunc_middle } from "@cocalc/util/misc";
12-
import { LICENSES_STYLE } from "./managed-licenses";
138
import { Virtuoso } from "react-virtuoso";
14-
import { SelectProject } from "@cocalc/frontend/projects/select-project";
9+
10+
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
11+
import { Loading, TimeAgo } from "@cocalc/frontend/components";
1512
import { SiteLicense } from "@cocalc/frontend/project/settings/site-license";
13+
import { SelectProject } from "@cocalc/frontend/projects/select-project";
14+
import { plural, trunc_middle } from "@cocalc/util/misc";
15+
import { LICENSES_STYLE } from "./managed-licenses";
16+
import { projects_with_licenses } from "./util";
1617

1718
export function ProjectsWithLicenses({}) {
1819
const [project_id, setProjectId] = useState<string | undefined>(undefined);

src/packages/frontend/antd-bootstrap.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
Tooltip,
2828
} from "antd";
2929
import type { MouseEventHandler } from "react";
30+
3031
import { inDarkMode } from "@cocalc/frontend/account/dark-mode";
3132
import { Gap } from "@cocalc/frontend/components/gap";
3233
import { r_join } from "@cocalc/frontend/components/r_join";
@@ -82,7 +83,7 @@ function parse_bsStyle(props: {
8283
let type =
8384
props.bsStyle == null
8485
? "default"
85-
: (BS_STYLE_TO_TYPE[props.bsStyle] ?? "default");
86+
: BS_STYLE_TO_TYPE[props.bsStyle] ?? "default";
8687

8788
let style: React.CSSProperties | undefined = undefined;
8889
// antd has no analogue of "success" & "warning", it's not clear to me what
@@ -351,9 +352,9 @@ export function Tabs(props: Readonly<TabsProps>) {
351352

352353
export function Tab(props: {
353354
id?: string;
354-
key?;
355+
key?: string;
355356
eventKey: string;
356-
title: any;
357+
title: string | JSX.Element;
357358
children?: any;
358359
style?: React.CSSProperties;
359360
}): AntdTabItem {

src/packages/frontend/course/commands.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { ENV_VARS_ICON } from "@cocalc/frontend/project/settings/environment";
2+
import { course } from "@cocalc/frontend/i18n";
23

34
export const COMMANDS = {
45
"add-students": {
56
icon: "users",
6-
label: "Add Students",
7+
label: course.add_students,
78
button: "+Student",
8-
title: "Add one or more students to this course.",
9+
title: course.add_students_tooltip,
910
onClick: ({ props }) => {
1011
const { actions } = props;
1112
actions.setModal("add-students");
@@ -248,7 +249,7 @@ export const COMMANDS = {
248249
},
249250
"delete-shared-project": {
250251
icon: "trash",
251-
label: "Delete Shared Project",
252+
label: course.delete_shared_project,
252253
button: "Delete",
253254
title:
254255
"Student projects will not be deleted. If you make a mistake, students can still be undeleted from the Student tab or using TimeTravel.",
@@ -259,10 +260,10 @@ export const COMMANDS = {
259260
},
260261
"create-shared-project": {
261262
icon: "users",
262-
label: "Create Shared Project",
263+
label: course.create_shared_project,
263264
button: "Shared",
264265
title:
265-
"Create a single common shared project, which everybody -- students and all collaborators on this project (your TAs and other instructors) -- have write access to.",
266+
"Create a single common shared project, which everybody students and all collaborators on this project (your TAs and other instructors) have write access to.",
266267
onClick: ({ props }) => {
267268
const { actions } = props;
268269
actions.setModal("create-shared-project");

src/packages/frontend/course/shared-project/delete-shared-project.tsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,35 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Popconfirm, Button, Card } from "antd";
6+
import { Button, Card, Popconfirm } from "antd";
7+
import { FormattedMessage, useIntl } from "react-intl";
8+
79
import { Icon } from "@cocalc/frontend/components";
10+
import { course } from "@cocalc/frontend/i18n";
811

912
export function DeleteSharedProjectPanel({ actions, settings, close }) {
13+
const intl = useIntl();
14+
1015
if (!settings.get("shared_project_id")) {
11-
return <Card title={"No Shared Project"}></Card>;
16+
return (
17+
<Card
18+
title={intl.formatMessage({
19+
id: "course.delete-shared-project.no_shared_project",
20+
defaultMessage: "No Shared Project",
21+
})}
22+
></Card>
23+
);
1224
}
25+
1326
return (
1427
<Card
1528
title={
1629
<Popconfirm
17-
title="Are you sure you want to delete the shared project?"
30+
title={intl.formatMessage({
31+
id: "course.delete-shared-project.confirmation",
32+
defaultMessage:
33+
"Are you sure you want to delete the shared project?",
34+
})}
1835
okText="Yes"
1936
cancelText="No"
2037
onConfirm={() => {
@@ -23,14 +40,18 @@ export function DeleteSharedProjectPanel({ actions, settings, close }) {
2340
}}
2441
>
2542
<Button danger>
26-
<Icon name="trash" /> Delete Shared Project...
43+
<Icon name="trash" />{" "}
44+
{intl.formatMessage(course.delete_shared_project)}...
2745
</Button>
2846
</Popconfirm>
2947
}
3048
>
31-
If you would like to delete the shared projects that was created for this
32-
course, you may do so by clicking above. All students will be removed from
33-
the deleted shared project.
49+
<FormattedMessage
50+
id="course.delete-shared-project.message"
51+
defaultMessage={`If you would like to delete the shared projects that was created for this course,
52+
you may do so by clicking above.
53+
All students will be removed from the deleted shared project.`}
54+
/>
3455
</Card>
3556
);
3657
}

src/packages/frontend/course/shared-project/shared-project-panel.tsx

Lines changed: 80 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
33
* License: MS-RSL – see LICENSE.md for details
44
*/
5-
65
import { UsergroupAddOutlined } from "@ant-design/icons";
76
import { Button, Card, Popconfirm } from "antd";
7+
import { FormattedMessage, useIntl } from "react-intl";
8+
89
import { AppRedux, useActions } from "@cocalc/frontend/app-framework";
9-
import { Icon } from "@cocalc/frontend/components";
10+
import { Icon, Paragraph } from "@cocalc/frontend/components";
11+
import { course } from "@cocalc/frontend/i18n";
1012
import { CancelText } from "@cocalc/frontend/i18n/components";
1113
import { CourseActions } from "../actions";
1214
import { CourseSettingsRecord } from "../store";
@@ -25,47 +27,68 @@ export function SharedProjectPanel({
2527
name,
2628
close,
2729
}: SharedProjectPanelProps) {
30+
const intl = useIntl();
31+
2832
const actions = useActions<CourseActions>({ name });
2933

34+
const haveSharedProject = !!settings.get("shared_project_id");
35+
3036
function panel_header_text(): string {
31-
if (settings.get("shared_project_id")) {
32-
return "Shared project that everybody can fully use";
33-
} else {
34-
return "Optionally create a shared project for everybody";
35-
}
37+
return intl.formatMessage(
38+
{
39+
id: "course.shared-project-panel.header",
40+
defaultMessage: `{haveSharedProject, select,
41+
true {Shared project that everybody can fully use}
42+
other {Optionally create a shared project for everybody}}`,
43+
},
44+
{ haveSharedProject },
45+
);
3646
}
3747

3848
function render_content() {
39-
if (settings.get("shared_project_id")) {
49+
if (haveSharedProject) {
4050
return render_has_shared_project();
4151
} else {
4252
return render_no_shared_project();
4353
}
4454
}
4555

56+
const icuVals = {
57+
b: (c) => <b>{c}</b>,
58+
i: (c) => <i>{c}</i>,
59+
p: (c) => <Paragraph>{c}</Paragraph>,
60+
secondary: (c) => <Paragraph type="secondary">{c}</Paragraph>,
61+
};
62+
4663
function render_has_shared_project() {
4764
return (
48-
<div>
49-
<div style={{ color: "#444" }}>
50-
<p>
51-
You created a common shared project, which everybody -- students and
52-
all collaborators on this project (your TAs and other instructors)
53-
-- have <b>write</b> access to. Use this project for collaborative
54-
in-class labs, course-wide chat rooms, and making miscellaneous
55-
materials available for students to experiment with together.
56-
</p>
57-
<p>
58-
When you created the shared project, everybody who has already
59-
created an account is added as a collaborator to the project.
60-
Whenever you re-open this course, any students or collaborators on
61-
the project that contains this course will be added to the shared
62-
project.
63-
</p>
64-
</div>
65+
<>
66+
<FormattedMessage
67+
id="course.shared-project-panel.have_project.message"
68+
defaultMessage={`
69+
<p>
70+
You created a common shared project, which everybody – students and
71+
all collaborators on this project (your TAs and other instructors)
72+
– have <b>write</b> access to. Use this project for collaborative
73+
in-class labs, course-wide chat rooms, and making miscellaneous
74+
materials available for students to experiment with together.
75+
</p>
76+
<secondary>
77+
When you created the shared project, everybody who has already
78+
created an account is added as a collaborator to the project.
79+
Whenever you re-open this course, any students or collaborators on
80+
the project that contains this course will be added to the shared
81+
project.
82+
</secondary>`}
83+
values={icuVals}
84+
/>
6585
<br />
6686
<div style={{ textAlign: "center" }}>
6787
<Button onClick={open_project} size={"large"} type={"primary"}>
68-
Open shared project
88+
<FormattedMessage
89+
id="course.shared-project-panel.have_project.button"
90+
defaultMessage={"Open shared project"}
91+
/>
6992
</Button>
7093
</div>
7194
<hr />
@@ -74,7 +97,7 @@ export function SharedProjectPanel({
7497
actions={actions}
7598
close={close}
7699
/>
77-
</div>
100+
</>
78101
);
79102
}
80103

@@ -88,34 +111,38 @@ export function SharedProjectPanel({
88111
function render_no_shared_project() {
89112
return (
90113
<div>
91-
<div style={{ color: "#444" }}>
92-
<p>
93-
<i>Optionally</i> create a single common shared project, which
94-
everybody -- students and all collaborators on this project (your
95-
TAs and other instructors) -- will have <b>write</b> access to. This
96-
can be useful for collaborative in-class labs, course-wide chat
97-
rooms, and making miscellanous materials available for students to
98-
experiment with together.
99-
</p>
100-
<p>
101-
When you create the shared project, everybody who has already
102-
created an account is added as a collaborator to the project.
103-
Whenever you re-open this course, any students or collaborators on
104-
the project that contains this course will be added to the shared
105-
project.
106-
</p>
107-
<p>
108-
After you create the shared project, you should move the shared
109-
project to a members only server or upgrade it in other ways if you
110-
want it to be more stable.
111-
</p>
112-
</div>
114+
<FormattedMessage
115+
id="course.shared-project-panel.create_project.message"
116+
defaultMessage={`
117+
<p>
118+
<i>Optionally</i> create a single common shared project, which
119+
everybody – students and all collaborators on this project (your
120+
TAs and other instructors) – will have <b>write</b> access to. This
121+
can be useful for collaborative in-class labs, course-wide chat
122+
rooms, and making miscellanous materials available for students to
123+
experiment with together.
124+
</p>
125+
<secondary>
126+
When you create the shared project, everybody who has already
127+
created an account is added as a collaborator to the project.
128+
Whenever you re-open this course, any students or collaborators on
129+
the project that contains this course will be added to the shared
130+
project.
131+
</secondary>
132+
<secondary>
133+
After you create the shared project, you should upgrade that project via a license as well.
134+
</secondary>`}
135+
values={icuVals}
136+
/>
113137
<br />
114138
<Popconfirm
115139
title={
116140
<div style={{ maxWidth: "400px" }}>
117-
Are you sure you want to create a shared project and add all
118-
students in this course as collaborators?
141+
<FormattedMessage
142+
id="course.shared-project-panel.create_project.confirmation"
143+
defaultMessage={`Are you sure you want to create a shared project
144+
and add all students in this course as collaborators?`}
145+
/>
119146
</div>
120147
}
121148
onConfirm={() => {
@@ -125,11 +152,11 @@ export function SharedProjectPanel({
125152
close?.();
126153
}
127154
}}
128-
okText="Create Shared Project"
155+
okText={intl.formatMessage(course.create_shared_project)}
129156
cancelText={<CancelText />}
130157
>
131158
<Button size={"large"} icon={<UsergroupAddOutlined />}>
132-
Create shared project...
159+
{intl.formatMessage(course.create_shared_project)}...
133160
</Button>
134161
</Popconfirm>
135162
</div>

src/packages/frontend/course/students/add-students.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from "@cocalc/util/misc";
2424
import { webapp_client } from "@cocalc/frontend/webapp-client";
2525
import { concat, sortBy } from "lodash";
26+
import { useIntl } from "react-intl";
2627

2728
interface Props {
2829
name: string;
@@ -39,6 +40,7 @@ export default function AddStudents({
3940
project_id,
4041
close,
4142
}: Props) {
43+
const intl = useIntl();
4244
const addSelectRef = useRef<HTMLSelectElement>(null);
4345
const studentAddInputRef = useRef(null);
4446
const actions = useActions<CourseActions>({ name });
@@ -426,16 +428,22 @@ export default function AddStudents({
426428

427429
const rows = add_search.trim().length == 0 && !studentInputFocused ? 1 : 4;
428430

431+
const placeholder = intl.formatMessage(
432+
{
433+
id: "course.add-students.textarea.placeholder",
434+
defaultMessage: `Add students by {include_name_search, select, true {names or} other {}} email addresses...`,
435+
},
436+
{ include_name_search },
437+
);
438+
429439
return (
430440
<Form onFinish={do_add_search} style={{ marginLeft: "15px" }}>
431441
<Row>
432442
<Col md={18}>
433443
<Form.Item style={{ margin: "0 0 5px 0" }}>
434444
<Input.TextArea
435445
ref={studentAddInputRef}
436-
placeholder={`Add students by ${
437-
include_name_search ? "names or " : ""
438-
} email addresses...`}
446+
placeholder={placeholder}
439447
value={add_search}
440448
rows={rows}
441449
onChange={() => student_add_input_onChange()}

0 commit comments

Comments
 (0)