Skip to content

Commit 30012a3

Browse files
committed
Use new CSE machine translations
1 parent 2742c42 commit 30012a3

File tree

3 files changed

+41
-40
lines changed

3 files changed

+41
-40
lines changed

src/commons/sideContent/content/SideContentCseMachine.tsx

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import { IconNames } from '@blueprintjs/icons';
1212
import { HotkeyItem } from '@mantine/hooks';
1313
import { bindActionCreators } from '@reduxjs/toolkit';
1414
import classNames from 'classnames';
15+
import { t } from 'i18next';
1516
import { Chapter } from 'js-slang/dist/types';
1617
import { debounce } from 'lodash';
1718
import React from 'react';
19+
import { Trans, useTranslation } from 'react-i18next';
1820
import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux';
1921
import HotKeys from 'src/commons/hotkeys/HotKeys';
2022
import { Output } from 'src/commons/repl/Repl';
@@ -540,13 +542,22 @@ export const SideContentCseMachine = connect(
540542
)(SideContentCseMachineBase);
541543

542544
const makeCseMachineTabFrom = (location: NonStoryWorkspaceLocation): SideContentTab => ({
543-
label: 'CSE Machine',
545+
label: t('sideContent:cseMachine.label'),
544546
iconName: IconNames.GLOBE,
545547
body: <SideContentCseMachine workspaceLocation={location} />,
546548
id: SideContentType.cseMachine
547549
});
548550

551+
const ItalicLink: React.FC<{ href: string; children?: React.ReactNode }> = ({ href, children }) => {
552+
return (
553+
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
554+
<i>{children}</i>
555+
</a>
556+
);
557+
};
558+
549559
const CseMachineDefaultText: React.FC<{ isJava: boolean }> = ({ isJava }) => {
560+
const { t } = useTranslation('sideContent', { keyPrefix: 'cseMachine' });
550561
return (
551562
<div
552563
id="cse-machine-default-text"
@@ -555,55 +566,45 @@ const CseMachineDefaultText: React.FC<{ isJava: boolean }> = ({ isJava }) => {
555566
>
556567
{isJava ? (
557568
<span>
558-
The CSEC machine generates control, stash, environment and class model diagrams adapted
559-
from the notation introduced in{' '}
560-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
561-
<i>
562-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
563-
Section 2
564-
</i>
565-
</a>
566-
{'. '}
567-
You have chosen the sublanguage{' '}
568-
<a href={`${Links.sourceDocs}java_csec/`} rel="noopener noreferrer" target="_blank">
569-
<i>Java CSEC</i>
570-
</a>
569+
<Trans
570+
ns="sideContent"
571+
i18nKey="cseMachine.csecDescription"
572+
components={[<ItalicLink href={Links.textbookChapter3_2} />]}
573+
/>{' '}
574+
<Trans
575+
ns="sideContent"
576+
i18nKey="cseMachine.javaCsec"
577+
components={[<ItalicLink href={`${Links.sourceDocs}java_csec/`} />]}
578+
/>
571579
</span>
572580
) : (
573581
<span>
574-
The CSE machine generates control, stash and environment model diagrams following a
575-
notation introduced in{' '}
576-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
577-
<i>
578-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
579-
Section 2
580-
</i>
581-
</a>
582+
<Trans
583+
ns="sideContent"
584+
i18nKey="cseMachine.cseDescription"
585+
components={[<ItalicLink href={Links.textbookChapter3_2} />]}
586+
/>
582587
</span>
583588
)}
584-
.
585589
<br />
586-
<br /> On this tab, the REPL will be hidden from view, so do check that your code has no
587-
errors before running the stepper. You may use this tool by running your program and then
588-
dragging the slider above to see the state of the control, stash and environment at different
589-
stages in the evaluation of your program. Clicking on the fast-forward button (double chevron)
590-
will take you to the next breakpoint in your program
590+
<br />
591+
{t('instructions')}
591592
<br />
592593
<br />
593594
<Divider />
594-
Some useful keyboard shortcuts:
595+
{t('shortcutsTitle')}
595596
<br />
596597
<br />
597-
a: Move to the first step
598+
{t('shortcuts.a')}
598599
<br />
599-
e: Move to the last step
600+
{t('shortcuts.e')}
600601
<br />
601-
f: Move to the next step
602+
{t('shortcuts.f')}
602603
<br />
603-
b: Move to the previous step
604+
{t('shortcuts.b')}
604605
<br />
605606
<br />
606-
Note that these shortcuts are only active when the browser focus is on this tab.
607+
{t('shortcutsNote')}
607608
</div>
608609
);
609610
};

src/i18n/locales/en/sideContent/cseMachine.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"maxStepsExceeded": "Maximum number of steps exceeded.",
33
"increaseStepLimit": "Please increase the step limit if you would like to see further evaluation.",
4-
"csecDescription": "The CSEC machine generates control, stash, environment and class model diagrams adapted from the notation introduced in Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3, Section 2.",
5-
"javaCsec": "You have chosen the sublanguage Java CSEC.",
6-
"cseDescription": "The CSE machine generates control, stash and environment model diagrams following a notation introduced in Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3, Section 2.",
4+
"csecDescription": "The CSEC machine generates control, stash, environment and class model diagrams adapted from the notation introduced in <0>Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3, Section 2</0>.",
5+
"javaCsec": "You have chosen the sublanguage <0>Java CSEC</0>.",
6+
"cseDescription": "The CSE machine generates control, stash and environment model diagrams following a notation introduced in <0>Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3, Section 2</0>.",
77
"instructions": "On this tab, the REPL will be hidden from view, so do check that your code has no errors before running the stepper. You may use this tool by running your program and then dragging the slider above to see the state of the control, stash and environment at different stages in the evaluation of your program. Clicking on the fast-forward button (double chevron) will take you to the next breakpoint in your program.",
88
"shortcutsTitle": "Some useful keyboard shortcuts:",
99
"shortcuts": {

src/i18n/locales/zh-SG/sideContent/cseMachine.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"maxStepsExceeded": "超出最大步骤数。",
33
"increaseStepLimit": "如果您希望查看进一步的评估,请增加步骤限制。",
4-
"csecDescription": "CSEC 机器生成控制、存储、环境和类模型图,这些图基于《计算机程序的构造和解释,JavaScript 版》第 3 章第 2 节中介绍的符号",
5-
"javaCsec": "您已选择子语言 Java CSEC。",
6-
"cseDescription": "CSE 机器生成控制、存储和环境模型图,这些图基于《计算机程序的构造和解释,JavaScript 版》第 3 章第 2 节中介绍的符号",
4+
"csecDescription": "CSEC 机器生成控制、存储、环境和类模型图,这些图基于<0>《计算机程序的构造和解释,JavaScript 版》第 3 章第 2 节</0>中介绍的符号",
5+
"javaCsec": "您已选择子语言 <0>Java CSEC</0>",
6+
"cseDescription": "CSE 机器生成控制、存储和环境模型图,这些图基于<0>《计算机程序的构造和解释,JavaScript 版》第 3 章第 2 节</0>中介绍的符号",
77
"instructions": "在此选项卡上,REPL 将被隐藏,因此请确保您的代码在运行前没有错误。您可以通过运行程序,然后拖动上方的滑块来查看程序评估过程中不同阶段的控制、存储和环境状态。点击快进按钮(双箭头)将跳到程序中的下一个断点。",
88
"shortcutsTitle": "一些有用的键盘快捷键:",
99
"shortcuts": {

0 commit comments

Comments
 (0)