Skip to content

Commit 9bb8b96

Browse files
committed
frontend/i18n: expand coverage
1 parent 7af752b commit 9bb8b96

File tree

13 files changed

+938
-64
lines changed

13 files changed

+938
-64
lines changed

src/packages/frontend/app/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ export class PageActions extends Actions<PageState> {
176176
if (change_history) {
177177
set_url("/admin");
178178
}
179-
set_window_title("Admin");
179+
set_window_title(intl.formatMessage(labels.admin));
180180
return;
181181
case "notifications":
182182
if (change_history) {
183183
set_url("/notifications");
184184
}
185-
set_window_title("Notifications");
185+
set_window_title(intl.formatMessage(labels.notifications));
186186
return;
187187
case undefined:
188188
return;

src/packages/frontend/i18n/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To get a feeling how this works, search in the source code for existing usages.
1212
- A `defineMessage({ id: "[...].[...].[label|title|tooltip|...]", defaultMessage:"..."})` is used when you define a message in a data structure, which will be referenced by a component. That "defined message" is basically a tagged object. You cannot use it directly in a component!
1313
- To make use of such a `defineMessage`, you have to get a hold of `const intl = useIntl()` and then `intl.formatMessage(the_message_object)`. That will render a string.
1414
- Note: There is a type `IntlMessage` defiend by us here in `./types.ts`. It requires `id` and `defaultMessage`. Search for `isIntlMessage` in the code base to see, how it is used to check what to do with it.
15+
- Outside the react context, you use `i18n/index::getIntl`.
1516

1617
Note: The "extract" step parses the source-code of all `*.tsx` files and only a few selected `*.ts` files. You cannot use variables where messages are defined, because the extract tool does not know what to do with them. So, for example, the files that define commands are `*.ts` files, and the messages it uses are referencing the exported messages defined in `i18n/common.ts`. Scanning all files just takes too long.
1718

src/packages/frontend/i18n/common.ts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ export const labels = defineMessages({
171171
defaultMessage: "Terminal",
172172
description: "Title of the Linux Terminal frame",
173173
},
174+
admin: {
175+
id: "labels.admin",
176+
defaultMessage: "Admin",
177+
},
178+
notifications: {
179+
id: "labels.notifications",
180+
defaultMessage: "Notifications",
181+
},
174182
snippets: {
175183
id: "labels.snippets",
176184
defaultMessage: "Snippets",
@@ -209,6 +217,11 @@ export const labels = defineMessages({
209217
description:
210218
"Tooltip on the menu enty to open the AI Assistant for generating documents",
211219
},
220+
stop: {
221+
id: "labels.stop",
222+
defaultMessage: "Stop",
223+
description: "Label on a button to stop an ongoing process",
224+
},
212225
});
213226

214227
export const menu = defineMessages({
@@ -327,6 +340,99 @@ export const jupyter = {
327340
defaultMessage:
328341
"Open the Jupyter command line console connected to the running kernel.",
329342
},
343+
browser_actions_trust_title: {
344+
id: "jupyter.editor.browser_actions.trust.title",
345+
defaultMessage: "Trust this Notebook?",
346+
description: "For a specific Jupyter Notebook",
347+
},
348+
browser_actions_trust_body: {
349+
id: "jupyter.editor.browser_actions.trust.body",
350+
defaultMessage:
351+
"A trusted Jupyter notebook may execute hidden Javascript code or carry out other attacks via malicious HTML. Selecting trust below, or evaluating any cell, will disable the code that strips dangerous HTML from this notebook. (NOTE: CoCalc does NOT implement the official Jupyter security model for trusted notebooks; in particular, we assume that you do trust collaborators on your CoCalc projects. Also, in many cases we still do not execute Javascript in HTML, even if the notebook is trusted.)",
352+
},
353+
close_and_halt_label: {
354+
id: "jupyter.editor.browser_actions.close_and_halt.label",
355+
defaultMessage: "Close and halt",
356+
},
357+
close_and_halt_body: {
358+
id: "jupyter.editor.browser_actions.close_and_halt.body",
359+
defaultMessage:
360+
"Are you sure you want to close this file and halt the kernel? All variable state will be lost.",
361+
},
362+
restart_and_run_all_title: {
363+
id: "jupyter.editor.restart_and_run_all.title",
364+
defaultMessage: "Restart kernel and run notebook",
365+
description: "For a Jupyter Notebook",
366+
},
367+
restart_and_run_all_body: {
368+
id: "jupyter.editor.restart_and_run_all.body",
369+
defaultMessage:
370+
"Are you sure you want to restart the kernel and run the notebook? All variable state and output will be reset, though past output is available in TimeTravel.",
371+
description: "For a Jupyter Notebook",
372+
},
373+
restart_and_run_all_stop: {
374+
id: "jupyter.editor.restart_and_run_all.stop",
375+
defaultMessage: "Run all (stop on first error)",
376+
description: "In a Jupyter Notebook, running all cells after a restart",
377+
},
378+
restart_and_run_all_nostop: {
379+
id: "jupyter.editor.restart_and_run_all.nostop",
380+
defaultMessage: "Run all (do not stop on errors)",
381+
description: "In a Jupyter Notebook, running all cells after a restart",
382+
},
383+
restart_and_run_all_no_halt_label: {
384+
id: "jupyter.editor.restart_and_run_all_no_halt.label",
385+
defaultMessage: "Restart and run all",
386+
description: "Button label for restarting a Jupyter Notebook",
387+
},
388+
restart_and_run_all_no_halt_title: {
389+
id: "jupyter.editor.restart_and_run_all_no_halt.title",
390+
defaultMessage:
391+
"Restart kernel and run all cells (do not stop on errors)",
392+
description: "Description for restarting a Jupyter Notebook",
393+
},
394+
restart_and_run_all_no_halt_body: {
395+
id: "jupyter.editor.restart_and_run_all_no_halt.body",
396+
defaultMessage:
397+
"Are you sure you want to restart the kernel and re-execute all cells? All variable state and output will be reset, though past output is available in TimeTravel.",
398+
description: "Description for restarting a Jupyter Notebook",
399+
},
400+
confirm_restart_label: {
401+
id: "jupyter.editor.confirm_restart.label",
402+
defaultMessage: "Restart",
403+
},
404+
confirm_restart_continue_label: {
405+
id: "jupyter.editor.confirm_restart.continue_label",
406+
defaultMessage: "Continue running",
407+
description:
408+
"Continue working with the Jupyter Notebook, not restarting Kernel",
409+
},
410+
confirm_restart_title: {
411+
id: "jupyter.editor.confirm_restart.title",
412+
defaultMessage: "Restart kernel?",
413+
},
414+
confirm_restart_body: {
415+
id: "jupyter.editor.confirm_restart.body",
416+
defaultMessage:
417+
"Do you want to restart the kernel? All variable values will be lost.",
418+
},
419+
confirm_halt_kernel_title: {
420+
id: "jupyter.editor.confirm_halt_kernel.title",
421+
defaultMessage: "Halt kernel?",
422+
},
423+
confirm_halt_kernel_body: {
424+
id: "jupyter.editor.confirm_halt_kernel.body",
425+
defaultMessage:
426+
"Do you want to kill the running kernel? All variable values will be lost. The kernel will only start if you try to evaluate some code.",
427+
},
428+
confirm_halt_kernel_continue: {
429+
id: "jupyter.editor.confirm_halt_kernel.continue",
430+
defaultMessage: "Continue running",
431+
},
432+
confirm_halt_kernel_halt: {
433+
id: "jupyter.editor.confirm_halt_kernel.halt",
434+
defaultMessage: "Halt",
435+
},
330436
}),
331437
commands: defineMessages({
332438
toggle_all_line_numbers: {
@@ -368,5 +474,41 @@ export const jupyter = {
368474
defaultMessage: "Run All",
369475
describe: "In a Jupyter Notebook, restart kernel and run all cells",
370476
},
477+
run_cell_and_insert_below: {
478+
id: "jupyter.commands.run_cell_and_insert_below",
479+
defaultMessage: "Run Selected Cells and Insert Below",
480+
description: "In a Jupyter Notebook",
481+
},
482+
run_cell_and_insert_below_title: {
483+
id: "jupyter.commands.run_cell_and_insert_below_title",
484+
defaultMessage:
485+
"Run all cells that are currently selected. Insert a new cell after the last one.",
486+
description: "In a Jupyter Notebook",
487+
},
488+
run_cell: {
489+
id: "jupyter.commands.run_cell",
490+
defaultMessage: "Run Selected Cells and Do Not Advance",
491+
description: "In a Jupyter Notebook",
492+
},
493+
run_cell_title: {
494+
id: "jupyter.commands.run_cell_title",
495+
defaultMessage:
496+
"Run all cells that are currently selected. Do not move the selection.",
497+
description: "In a Jupyter Notebook",
498+
},
499+
run_cell_and_select_next: {
500+
id: "jupyter.commands.run_cell_and_select_next",
501+
defaultMessage: "Run Selected Cells",
502+
description: "In a Jupyter Notebook",
503+
},
504+
run_current_cell: {
505+
id: "jupyter.commands.run_current_cell",
506+
defaultMessage: "Run Current Cell",
507+
},
508+
interrupt_kernel: {
509+
id: "jupyter.commands.interrupt_kernel",
510+
defaultMessage: "Interrupt Kernel (Stop)",
511+
description: "In a Jupyter Notebook, interrup the running kernel",
512+
},
371513
}),
372514
};

0 commit comments

Comments
 (0)