@@ -103,6 +108,7 @@ const BatteryIndicator: React.VFC = (_props) => {
const StatusBar: React.VFC = (_props) => {
const connection = useSelector((s) => s.ble.connection);
+ const [i18n] = useI18n();
return (
{
>
{connection === BleConnectionState.Connected && (
<>
-
-
+
+
>
)}
diff --git a/src/status-bar/i18n.test.ts b/src/status-bar/i18n.test.ts
index d5939dd8..d0ceda4a 100644
--- a/src/status-bar/i18n.test.ts
+++ b/src/status-bar/i18n.test.ts
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
-// Copyright (c) 2020-2021 The Pybricks Authors
+// Copyright (c) 2020-2022 The Pybricks Authors
import { lookup } from '../../test';
-import { MessageId } from './i18n';
-import en from './i18n.en.json';
+import { I18nId } from './i18n';
+import en from './translations/en.json';
-describe('Ensure .json file has matches for MessageIds', () => {
- test.each(Object.values(MessageId))('%s', (id) => {
+describe('Ensure .json file has matches for I18nId', () => {
+ test.each(Object.values(I18nId))('%s', (id) => {
expect(lookup(en, id)).toBeDefined();
});
});
diff --git a/src/status-bar/i18n.ts b/src/status-bar/i18n.ts
index 5abced99..f00d261a 100644
--- a/src/status-bar/i18n.ts
+++ b/src/status-bar/i18n.ts
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
-// Copyright (c) 2021 The Pybricks Authors
+// Copyright (c) 2021-2022 The Pybricks Authors
//
// Status bar translation keys.
-export enum MessageId {
+export enum I18nId {
BatteryTitle = 'battery.title',
BatteryLow = 'battery.low',
BatteryOk = 'battery.ok',
diff --git a/src/status-bar/i18n.en.json b/src/status-bar/translations/en.json
similarity index 100%
rename from src/status-bar/i18n.en.json
rename to src/status-bar/translations/en.json
diff --git a/src/terminal/Terminal.tsx b/src/terminal/Terminal.tsx
index 09e1f025..6ce5a1cc 100644
--- a/src/terminal/Terminal.tsx
+++ b/src/terminal/Terminal.tsx
@@ -12,8 +12,7 @@ import { FitAddon } from 'xterm-addon-fit';
import { isMacOS } from '../utils/os';
import { TerminalContext } from './TerminalContext';
import { receiveData } from './actions';
-import { TerminalStringId } from './i18n';
-import en from './i18n.en.json';
+import { I18nId } from './i18n';
import 'xterm/css/xterm.css';
@@ -55,7 +54,7 @@ function createContextMenu(
xterm: XTerm,
): (props: ContextMenu2ContentProps) => JSX.Element {
const contextMenu = (_props: ContextMenu2ContentProps): JSX.Element => {
- const [i18n] = useI18n({ id: 'terminal', translations: { en }, fallback: en });
+ const [i18n] = useI18n();
return (
diff --git a/src/terminal/i18n.en.json b/src/terminal/i18n.en.json
deleted file mode 100644
index 3575aa9b..00000000
--- a/src/terminal/i18n.en.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "terminal": {
- "copy": "Copy",
- "paste": "Paste",
- "selectAll": "Select All",
- "clear": "Clear"
- }
-}
diff --git a/src/terminal/i18n.test.ts b/src/terminal/i18n.test.ts
index 920f97b6..d0ceda4a 100644
--- a/src/terminal/i18n.test.ts
+++ b/src/terminal/i18n.test.ts
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
-// Copyright (c) 2020 The Pybricks Authors
+// Copyright (c) 2020-2022 The Pybricks Authors
import { lookup } from '../../test';
-import { TerminalStringId } from './i18n';
-import en from './i18n.en.json';
+import { I18nId } from './i18n';
+import en from './translations/en.json';
-describe('Ensure .json file has matches for TerminalStringIds', () => {
- test.each(Object.values(TerminalStringId))('%s', (id) => {
+describe('Ensure .json file has matches for I18nId', () => {
+ test.each(Object.values(I18nId))('%s', (id) => {
expect(lookup(en, id)).toBeDefined();
});
});
diff --git a/src/terminal/i18n.ts b/src/terminal/i18n.ts
index 330dd5d0..e8091901 100644
--- a/src/terminal/i18n.ts
+++ b/src/terminal/i18n.ts
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
-// Copyright (c) 2020 The Pybricks Authors
+// Copyright (c) 2020-2022 The Pybricks Authors
//
// Terminal translation keys.
-export enum TerminalStringId {
- Copy = 'terminal.copy',
- Paste = 'terminal.paste',
- SelectAll = 'terminal.selectAll',
- Clear = 'terminal.clear',
+export enum I18nId {
+ Copy = 'copy',
+ Paste = 'paste',
+ SelectAll = 'selectAll',
+ Clear = 'clear',
}
diff --git a/src/terminal/translations/en.json b/src/terminal/translations/en.json
new file mode 100644
index 00000000..2a7e5caa
--- /dev/null
+++ b/src/terminal/translations/en.json
@@ -0,0 +1,6 @@
+{
+ "copy": "Copy",
+ "paste": "Paste",
+ "selectAll": "Select All",
+ "clear": "Clear"
+}
diff --git a/src/toolbar/ActionButton.tsx b/src/toolbar/ActionButton.tsx
index 7f749cba..4c6d5c5c 100644
--- a/src/toolbar/ActionButton.tsx
+++ b/src/toolbar/ActionButton.tsx
@@ -14,8 +14,7 @@ import { useI18n } from '@shopify/react-i18n';
import React, { useEffect, useMemo, useState } from 'react';
import { tooltipDelay } from '../app/constants';
import { pointerEventsNone } from '../utils/react';
-import { TooltipId } from './i18n';
-import en from './i18n.en.json';
+import { I18nId } from './i18n';
const smallScreenThreshold = 700;
@@ -25,9 +24,9 @@ export interface ActionButtonProps {
/** Keyboard shortcut. */
readonly keyboardShortcut?: string;
/** Tooltip text that appears when hovering over the button. */
- readonly tooltip: TooltipId;
+ readonly tooltip: I18nId;
/** Tooltip text that appears when hovering over the button and @showProgress is true. */
- readonly progressTooltip?: TooltipId;
+ readonly progressTooltip?: I18nId;
/** Icon shown on the button. */
readonly icon: string;
/** When true or undefined, the button is enabled. */
@@ -51,7 +50,7 @@ const ActionButton: React.VoidFunctionComponent
= ({
progress,
onAction,
}) => {
- const [i18n] = useI18n({ id: 'actionButton', translations: { en }, fallback: en });
+ const [i18n] = useI18n();
const [isSmallScreen, setIsSmallScreen] = useState(
window.innerWidth <= smallScreenThreshold,
diff --git a/src/toolbar/OpenFileButton.tsx b/src/toolbar/OpenFileButton.tsx
index 0ca9fff9..496280bd 100644
--- a/src/toolbar/OpenFileButton.tsx
+++ b/src/toolbar/OpenFileButton.tsx
@@ -8,8 +8,7 @@ import React, { useEffect, useState } from 'react';
import { useDropzone } from 'react-dropzone';
import { tooltipDelay } from '../app/constants';
import { pointerEventsNone } from '../utils/react';
-import { TooltipId } from './i18n';
-import en from './i18n.en.json';
+import { I18nId } from './i18n';
const smallScreenThreshold = 700;
export interface OpenFileButtonProps {
@@ -18,7 +17,7 @@ export interface OpenFileButtonProps {
/** The accepted file extension */
readonly fileExtension: string;
/** Tooltip text that appears when hovering over the button. */
- readonly tooltip: TooltipId;
+ readonly tooltip: I18nId;
/** Icon shown on the button. */
readonly icon: string;
/** When true or undefined, the button is enabled. */
@@ -50,11 +49,7 @@ const OpenFileButton: React.VoidFunctionComponent = ({
onReject,
onClick,
}) => {
- const [i18n] = useI18n({
- id: 'openFileButton',
- translations: { en },
- fallback: en,
- });
+ const [i18n] = useI18n();
const [isSmallScreen, setIsSmallScreen] = useState(
window.innerWidth <= smallScreenThreshold,
@@ -108,7 +103,7 @@ const OpenFileButton: React.VoidFunctionComponent = ({
{
- test.each(Object.values(TooltipId))('%s', (id) => {
+describe('Ensure .json file has matches for I18nId', () => {
+ test.each(Object.values(I18nId))('%s', (id) => {
expect(lookup(en, id)).toBeDefined();
});
});
diff --git a/src/toolbar/i18n.ts b/src/toolbar/i18n.ts
index 1221aa09..557b0e31 100644
--- a/src/toolbar/i18n.ts
+++ b/src/toolbar/i18n.ts
@@ -3,7 +3,7 @@
//
// Toolbar button translation keys.
-export enum TooltipId {
+export enum I18nId {
Run = 'run.action.tooltip',
RunProgress = 'run.progress.tooltip',
Stop = 'stop.tooltip',
diff --git a/src/toolbar/i18n.en.json b/src/toolbar/translations/en.json
similarity index 100%
rename from src/toolbar/i18n.en.json
rename to src/toolbar/translations/en.json