Skip to content

Commit c2cb457

Browse files
committed
improve: use i18n
1 parent 335b442 commit c2cb457

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/editor/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2023 The Pybricks Authors
2+
// Copyright (c) 2020-2024 The Pybricks Authors
33

44
import './editor.scss';
55
import {
@@ -510,7 +510,7 @@ const Editor: React.FunctionComponent = () => {
510510
<ContextMenu
511511
className={classNames('pb-editor-tabpanel', isEmpty && 'pb-empty')}
512512
role="tabpanel"
513-
aria-label={isEmpty ? i18n.translate('welcome') : fileName}
513+
aria-label={isEmpty ? i18n.translate('welcome.label') : fileName}
514514
// NB: we have to create a new context menu each time it is
515515
// shown in order to get some state, like canUndo and canRedo
516516
// that don't have events to monitor changes.

src/editor/Welcome.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Two from 'two.js';
1111
import { useTernaryDarkMode } from 'usehooks-ts';
1212
import { Activity, useActivitiesSelectedActivity } from '../activities/hooks';
1313
import { explorerCreateNewFile } from '../explorer/actions';
14+
import { useI18n } from './i18n';
1415
import logoSvg from './logo.svg';
1516

1617
const defaultRotation = -Math.PI / 9; // radians
@@ -65,6 +66,7 @@ type WelcomeProps = {
6566
};
6667

6768
const Welcome: React.FunctionComponent<WelcomeProps> = ({ isVisible }) => {
69+
const i18n = useI18n();
6870
const dispatch = useDispatch();
6971
const stateRef = useRef<State>({
7072
rotation: defaultRotation,
@@ -182,13 +184,13 @@ const Welcome: React.FunctionComponent<WelcomeProps> = ({ isVisible }) => {
182184
<div className="logo" ref={elementRef}></div>
183185
<div className="shortcuts">
184186
<dl>
185-
<dt>Open existing project</dt>
187+
<dt>{i18n.translate('welcome.openProject')}</dt>
186188
<dd>
187189
<Button icon={<Document />} onClick={handleOpenExplorer} />
188190
</dd>
189191
</dl>
190192
<dl>
191-
<dt>Open a new project</dt>
193+
<dt>{i18n.translate('welcome.newProject')}</dt>
192194
<dd>
193195
<Button icon={<Plus />} onClick={handleOpenNewProject} />
194196
</dd>

src/editor/translations/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"tablist": {
33
"label": "Editor"
44
},
5-
"welcome": "Welcome",
65
"placeholder": "Write your program here...",
76
"check": "Check syntax",
87
"toggleDocs": "Toggle documentation",
@@ -16,5 +15,10 @@
1615
"docs": {
1716
"show": "Show documentation",
1817
"hide": "Hide documentation"
18+
},
19+
"welcome": {
20+
"label": "Welcome",
21+
"openProject": "Open existing project",
22+
"newProject": "Open a new project"
1923
}
2024
}

0 commit comments

Comments
 (0)