Skip to content

Commit 0c5f515

Browse files
committed
Merge branch 'master' of github.com:sagemathinc/cocalc
2 parents f208d26 + 3605c72 commit 0c5f515

File tree

30 files changed

+1125
-138
lines changed

30 files changed

+1125
-138
lines changed

src/packages/frontend/app/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ export const Page: React.FC = () => {
311311
}}
312312
name={"projects"}
313313
active_top_tab={active_top_tab}
314-
tooltip="Show all the projects on which you collaborate."
314+
tooltip={intl.formatMessage({
315+
id: "page.project_nav.tooltip",
316+
defaultMessage: "Show all the projects on which you collaborate.",
317+
})}
315318
icon="edit"
316319
label={intl.formatMessage(labels.projects)}
317320
/>

src/packages/frontend/chat/chat-indicator.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
// this is... so for now it still sort of toggles. For now things
1010
// do work properly via a hack in close_chat in project_actions.
1111

12+
import { filename_extension } from "@cocalc/util/misc";
1213
import { Button, Tooltip } from "antd";
1314
import { debounce } from "lodash";
14-
import { filename_extension } from "@cocalc/util/misc";
1515
import { useMemo } from "react";
16-
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
17-
import { Icon } from "@cocalc/frontend/components/icon";
16+
import { FormattedMessage, useIntl } from "react-intl";
17+
1818
import { UsersViewing } from "@cocalc/frontend/account/avatar/users-viewing";
19+
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
1920
import { HiddenXS } from "@cocalc/frontend/components";
21+
import { Icon } from "@cocalc/frontend/components/icon";
2022
import track from "@cocalc/frontend/user-tracking";
23+
import { labels } from "../i18n";
2124

2225
export type ChatState =
2326
| "" // not opened (also undefined counts as not open)
@@ -29,12 +32,12 @@ const CHAT_INDICATOR_STYLE: React.CSSProperties = {
2932
fontSize: "15pt",
3033
paddingTop: "3px",
3134
cursor: "pointer",
32-
};
35+
} as const;
3336

3437
const USERS_VIEWING_STYLE: React.CSSProperties = {
3538
maxWidth: "120px",
3639
marginRight: "5px",
37-
};
40+
} as const;
3841

3942
interface Props {
4043
project_id: string;
@@ -47,6 +50,7 @@ export function ChatIndicator({ project_id, path, chatState }: Props) {
4750
...CHAT_INDICATOR_STYLE,
4851
...{ display: "flex" },
4952
};
53+
5054
return (
5155
<div style={style}>
5256
<UsersViewing
@@ -60,6 +64,8 @@ export function ChatIndicator({ project_id, path, chatState }: Props) {
6064
}
6165

6266
function ChatButton({ project_id, path, chatState }) {
67+
const intl = useIntl();
68+
6369
const toggleChat = debounce(
6470
() => {
6571
const actions = redux.getProjectActions(project_id);
@@ -92,7 +98,10 @@ function ChatButton({ project_id, path, chatState }) {
9298
title={
9399
<span>
94100
<Icon name="comment" style={{ marginRight: "5px" }} />
95-
Hide or Show Document Chat
101+
<FormattedMessage
102+
id="chat.chat-indicator.tooltip"
103+
defaultMessage={"Hide or Show Document Chat"}
104+
/>
96105
</span>
97106
}
98107
placement={"leftTop"}
@@ -107,7 +116,9 @@ function ChatButton({ project_id, path, chatState }) {
107116
>
108117
<Icon name="comment" />
109118
<HiddenXS>
110-
<span style={{ marginLeft: "5px" }}>Chat</span>
119+
<span style={{ marginLeft: "5px" }}>
120+
{intl.formatMessage(labels.chat)}
121+
</span>
111122
</HiddenXS>
112123
</Button>
113124
</Tooltip>

src/packages/frontend/frame-editors/frame-tree/commands/format-commands.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,19 @@ const FORMAT_SPEC = {
220220
description: "a quoted text in a text document",
221221
}),
222222
},
223-
table: { icon: "table", label: "Table", title: "Insert a table" },
223+
table: {
224+
icon: "table",
225+
label: defineMessage({
226+
id: "command.format.table.label",
227+
defaultMessage: "Table",
228+
description: "a table text in a text document",
229+
}),
230+
title: defineMessage({
231+
id: "command.format.table.tooltip",
232+
defaultMessage: "Insert a table",
233+
description: "a table text in a text document",
234+
}),
235+
},
224236
horizontalRule: {
225237
label: defineMessage({
226238
id: "command.format.horizontalRule.label",
@@ -388,7 +400,11 @@ const FORMAT_MENUS = {
388400
icon: "text-height",
389401
isVisible: "format_action", // todo
390402
name: "font-size",
391-
label: "Size",
403+
label: defineMessage({
404+
id: "command.format.font_size.label",
405+
defaultMessage: "Size",
406+
description: "change the font size in a text document",
407+
}),
392408
children: FONT_SIZES.map((size) => {
393409
return {
394410
name: `${size}`,
@@ -407,7 +423,11 @@ const FORMAT_MENUS = {
407423
icon: "font",
408424
isVisible: "format_action", // todo
409425
name: "font-family",
410-
label: "Family",
426+
label: defineMessage({
427+
id: "command.format.font_family.label",
428+
defaultMessage: "Family",
429+
description: "change the font family in a text document",
430+
}),
411431
children: FONT_FACES.map((family) => {
412432
return {
413433
name: family,
@@ -422,7 +442,11 @@ const FORMAT_MENUS = {
422442
icon: "header",
423443
isVisible: "format_action", // todo
424444
name: "header",
425-
label: "Heading",
445+
label: defineMessage({
446+
id: "command.format.font_heading.label",
447+
defaultMessage: "Heading",
448+
description: "change the heading in a text document",
449+
}),
426450
children: range(1, 7).map((heading) => {
427451
return {
428452
name: `heading-${heading}`,
@@ -436,7 +460,11 @@ const FORMAT_MENUS = {
436460
icon: "colors",
437461
isVisible: "format_action",
438462
name: "color",
439-
label: "Color",
463+
label: defineMessage({
464+
id: "command.format.font_color.label",
465+
defaultMessage: "Color",
466+
description: "change the font color in a text document",
467+
}),
440468
children: [
441469
{
442470
stayOpenOnClick: true,
@@ -462,7 +490,11 @@ const FORMAT_MENUS = {
462490
icon: "text",
463491
isVisible: "format_action",
464492
name: "text",
465-
label: "Text",
493+
label: defineMessage({
494+
id: "command.format.font_alignment.label",
495+
defaultMessage: "Alignment",
496+
description: "change the paragraph alignment in a text document",
497+
}),
466498
children: [
467499
"justifyleft",
468500
"justifycenter",

src/packages/frontend/frame-editors/frame-tree/commands/generic-commands.tsx

Lines changed: 91 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Input } from "antd";
77
import { debounce } from "lodash";
88
import { useEffect, useRef } from "react";
9-
import { defineMessage, IntlShape } from "react-intl";
9+
import { defineMessage, IntlShape, useIntl } from "react-intl";
1010

1111
import { set_account_table } from "@cocalc/frontend/account/util";
1212
import { redux } from "@cocalc/frontend/app-framework";
@@ -376,8 +376,11 @@ addCommands({
376376

377377
clear: {
378378
group: "action",
379-
button: "Clear",
380-
label: "Clear Frame",
379+
button: labels.clear,
380+
label: defineMessage({
381+
id: "command.generic.clear.label",
382+
defaultMessage: "Clear Frame",
383+
}),
381384
icon: <Icon unicode={0x2620} />,
382385
popconfirm: {
383386
title: "Clear this frame?",
@@ -386,9 +389,16 @@ addCommands({
386389

387390
pause: {
388391
group: "action",
389-
button: "Pause",
390-
icon: "pause",
391-
label: ({ props }) => {
392+
button: ({ props, intl }) => (
393+
<span>
394+
{intl.formatMessage(menu.pause_resume, { pause: props.is_paused })}
395+
</span>
396+
),
397+
icon: ({ props }) => (props.is_paused ? "play" : "pause"),
398+
label: ({ props, intl }) => {
399+
const label = intl.formatMessage(menu.pause_resume, {
400+
pause: props.is_paused,
401+
});
392402
if (props.is_paused) {
393403
return (
394404
<div
@@ -399,13 +409,17 @@ addCommands({
399409
padding: "0 20px",
400410
}}
401411
>
402-
Resume
412+
{label}
403413
</div>
404414
);
415+
} else {
416+
return <span>{label}</span>;
405417
}
406-
return <span>Pause</span>;
407418
},
408-
title: "Pause this frame temporarily",
419+
title: defineMessage({
420+
id: "command.generic.pause.tooltip",
421+
defaultMessage: "Temporarily pause output in this terminal.",
422+
}),
409423
onClick: ({ props }) => {
410424
if (props.is_paused) {
411425
props.actions.unpause(props.id);
@@ -618,21 +632,37 @@ addCommands({
618632
},
619633
clean: {
620634
group: "build",
621-
label: "Delete Aux Files",
622-
title: "Delete all temporary files left around from builds",
635+
label: defineMessage({
636+
id: "command.generic.clean.label",
637+
defaultMessage: "Delete Aux Files",
638+
description: "Clean up auxiliary build files",
639+
}),
640+
title: defineMessage({
641+
id: "command.generic.clean.title",
642+
defaultMessage: "Delete all temporary files left around from builds",
643+
description: "Clean up auxiliary build files",
644+
}),
623645
icon: "trash",
624646
},
625647

626648
rescan_latex_directive: {
627649
group: "scan",
628-
label: "Scan for Build Directives",
629-
title: (
630-
<>
631-
Rescan the document for build directives, starting{" "}
632-
<code>'% !TeX program = xelatex, pdflatex, etc'</code> or{" "}
633-
<code>'% !TeX cocalc = exact command line'</code>
634-
</>
635-
),
650+
label: defineMessage({
651+
id: "command.generic.rescan_latex_directive.label",
652+
defaultMessage: "Scan for Build Directives",
653+
}),
654+
title: ({ intl }) =>
655+
intl.formatMessage(
656+
{
657+
id: "command.generic.rescan_latex_directive.title",
658+
defaultMessage: `Rescan the LaTeX document for build directives.
659+
This looks for lines starting with {code1} or {code2}.`,
660+
},
661+
{
662+
code1: <code>'% !TeX program = xelatex, pdflatex, etc'</code>,
663+
code2: <code>'% !TeX cocalc = exact command line'</code>,
664+
},
665+
),
636666
icon: "reload",
637667
},
638668
sync: {
@@ -845,8 +875,14 @@ addCommands({
845875
},
846876
download_pdf: {
847877
group: "export",
848-
label: "Download PDF",
849-
title: "Download the PDF file",
878+
label: defineMessage({
879+
id: "menu.generic.download_pdf.label",
880+
defaultMessage: "Download PDF",
881+
}),
882+
title: defineMessage({
883+
id: "menu.generic.download_pdf.tooltip",
884+
defaultMessage: "Download the PDF file",
885+
}),
850886
icon: "cloud-download",
851887
},
852888
upload: {
@@ -975,8 +1011,13 @@ addCommands({
9751011
pos: 5,
9761012
group: "help-link",
9771013
icon: "comment",
978-
label: "Chat With Collaborators or AI",
979-
button: "Chat",
1014+
label: defineMessage({
1015+
id: "command.generic.chat.label",
1016+
defaultMessage: "Chat with Collaborators or AI",
1017+
description:
1018+
"Opens a chatroom next to the document to chat with other users (collaborators) or an AI chatbot",
1019+
}),
1020+
button: labels.chat,
9801021
title:
9811022
"Open chat on the side of this file for chatting with project collaborators or AI about this file.",
9821023
onClick: ({ props }) => {
@@ -988,10 +1029,18 @@ addCommands({
9881029
pos: 6,
9891030
group: "help-link",
9901031
icon: "medkit",
991-
label: "Support Ticket",
1032+
label: defineMessage({
1033+
id: "command.generic.support.label",
1034+
defaultMessage: "Support Ticket",
1035+
description: "Contact support by creating a support ticket to get help",
1036+
}),
9921037
button: labels.support,
993-
title:
994-
"Create a support ticket. Ask the people at CoCalc a question, report a bug, etc.",
1038+
title: defineMessage({
1039+
id: "command.generic.support.tooltip",
1040+
defaultMessage:
1041+
"Create a support ticket. Ask the people at CoCalc a question, report a bug, etc.",
1042+
description: "Contact support by creating a support ticket to get help",
1043+
}),
9951044
onClick: () => {
9961045
openSupportTab();
9971046
},
@@ -1001,9 +1050,12 @@ addCommands({
10011050
pos: 10,
10021051
group: "help-link",
10031052
icon: "youtube",
1004-
label: "Videos",
1005-
button: "Videos",
1006-
title: "Browse videos about CoCalc.",
1053+
label: labels.videos,
1054+
button: labels.videos,
1055+
title: defineMessage({
1056+
id: "command.generic.videos.tooltip",
1057+
defaultMessage: "Browse videos about CoCalc.",
1058+
}),
10071059
onClick: () => {
10081060
openNewTab(
10091061
"https://www.youtube.com/playlist?list=PLOEk1mo1p5tJmEuAlou4JIWZFH7IVE2PZ",
@@ -1015,7 +1067,12 @@ addCommands({
10151067
alwaysShow: true,
10161068
pos: 0,
10171069
group: "search-commands",
1018-
title: "Search through all commands for this document frame.",
1070+
title: defineMessage({
1071+
id: "command.generic.search_commands.tooltip",
1072+
defaultMessage: "Search through all commands for this document frame.",
1073+
description:
1074+
"Menu entry, where users can search through all available menu commands",
1075+
}),
10191076
label: ({ helpSearch, setHelpSearch }) => {
10201077
return (
10211078
<SearchBox helpSearch={helpSearch} setHelpSearch={setHelpSearch} />
@@ -1300,7 +1357,9 @@ function fileAction(action) {
13001357
}
13011358

13021359
function SearchBox({ setHelpSearch, helpSearch }) {
1360+
const intl = useIntl();
13031361
const didFocus = useRef<boolean>(false);
1362+
13041363
useEffect(() => {
13051364
return () => {
13061365
if (didFocus.current) {
@@ -1309,10 +1368,11 @@ function SearchBox({ setHelpSearch, helpSearch }) {
13091368
}
13101369
};
13111370
}, []);
1371+
13121372
return (
13131373
<Input.Search
13141374
autoFocus
1315-
placeholder="Search"
1375+
placeholder={intl.formatMessage(labels.search)}
13161376
allowClear
13171377
value={helpSearch}
13181378
onChange={(e) => setHelpSearch(e.target.value)}

0 commit comments

Comments
 (0)