From 738496a630a11dc10493ad01d2f2e9caabab02fc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 11 Oct 2023 17:42:42 +0100 Subject: [PATCH 1/2] Fix untranslated headings in the devtools dialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/DevtoolsDialog.tsx | 4 ++-- src/components/views/dialogs/devtools/BaseTool.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.tsx b/src/components/views/dialogs/DevtoolsDialog.tsx index a2bcd0a8a2a..f0f97e9ff80 100644 --- a/src/components/views/dialogs/DevtoolsDialog.tsx +++ b/src/components/views/dialogs/DevtoolsDialog.tsx @@ -69,7 +69,7 @@ interface IProps { onFinished(finished?: boolean): void; } -type ToolInfo = [label: string, tool: Tool]; +type ToolInfo = [label: TranslationKey, tool: Tool]; const DevtoolsDialog: React.FC = ({ roomId, threadRootId, onFinished }) => { const [tool, setTool] = useState(null); @@ -116,7 +116,7 @@ const DevtoolsDialog: React.FC = ({ roomId, threadRootId, onFinished }) ); } - const label = tool ? tool[0] : _t("devtools|toolbox"); + const label = tool ? _t(tool[0]) : _t("devtools|toolbox"); return ( diff --git a/src/components/views/dialogs/devtools/BaseTool.tsx b/src/components/views/dialogs/devtools/BaseTool.tsx index c6bd3176247..62883540687 100644 --- a/src/components/views/dialogs/devtools/BaseTool.tsx +++ b/src/components/views/dialogs/devtools/BaseTool.tsx @@ -19,13 +19,13 @@ import React, { createContext, ReactNode, useState } from "react"; import { Room } from "matrix-js-sdk/src/matrix"; import classNames from "classnames"; -import { _t } from "../../../../languageHandler"; +import { _t, TranslationKey } from "../../../../languageHandler"; import { XOR } from "../../../../@types/common"; import { Tool } from "../DevtoolsDialog"; export interface IDevtoolsProps { onBack(): void; - setTool(label: string, tool: Tool): void; + setTool(label: TranslationKey, tool: Tool): void; } interface IMinProps extends Pick { From 168b7d0c3bca2252314c1b20a4a18b79ad59a09b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 11 Oct 2023 17:52:51 +0100 Subject: [PATCH 2/2] Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/devtools/AccountData.tsx | 8 ++++---- src/components/views/dialogs/devtools/BaseTool.tsx | 4 ++-- src/components/views/dialogs/devtools/Event.tsx | 4 ++-- src/components/views/dialogs/devtools/RoomState.tsx | 6 +++--- src/components/views/dialogs/devtools/SettingExplorer.tsx | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/views/dialogs/devtools/AccountData.tsx b/src/components/views/dialogs/devtools/AccountData.tsx index 693ae0cd34b..635becac3fb 100644 --- a/src/components/views/dialogs/devtools/AccountData.tsx +++ b/src/components/views/dialogs/devtools/AccountData.tsx @@ -22,7 +22,7 @@ import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { EventEditor, EventViewer, eventTypeField, IEditorProps, stringify } from "./Event"; import FilteredList from "./FilteredList"; -import { _t } from "../../../../languageHandler"; +import { _td, TranslationKey } from "../../../../languageHandler"; export const AccountDataEventEditor: React.FC = ({ mxEvent, onBack }) => { const cli = useContext(MatrixClientContext); @@ -54,7 +54,7 @@ export const RoomAccountDataEventEditor: React.FC = ({ mxEvent, on interface IProps extends IDevtoolsProps { events: Map; Editor: React.FC; - actionLabel: string; + actionLabel: TranslationKey; } const BaseAccountDataExplorer: React.FC = ({ events, Editor, actionLabel, onBack, setTool }) => { @@ -98,7 +98,7 @@ export const AccountDataExplorer: React.FC = ({ onBack, setTool @@ -112,7 +112,7 @@ export const RoomAccountDataExplorer: React.FC = ({ onBack, setT diff --git a/src/components/views/dialogs/devtools/BaseTool.tsx b/src/components/views/dialogs/devtools/BaseTool.tsx index 62883540687..49bcd76009d 100644 --- a/src/components/views/dialogs/devtools/BaseTool.tsx +++ b/src/components/views/dialogs/devtools/BaseTool.tsx @@ -35,7 +35,7 @@ interface IMinProps extends Pick { } interface IProps extends IMinProps { - actionLabel: string; + actionLabel: TranslationKey; onAction(): Promise; } @@ -69,7 +69,7 @@ const BaseTool: React.FC> = ({ }); }; - actionButton = ; + actionButton = ; } return ( diff --git a/src/components/views/dialogs/devtools/Event.tsx b/src/components/views/dialogs/devtools/Event.tsx index d740b95b352..4b85dbe3f6f 100644 --- a/src/components/views/dialogs/devtools/Event.tsx +++ b/src/components/views/dialogs/devtools/Event.tsx @@ -117,7 +117,7 @@ export const EventEditor: React.FC = ({ fieldDefs, defaultCon }; return ( - +
{fields}
= ({ mxEvent, onBack, Editor, e }; return ( - + {stringify(mxEvent.event)} ); diff --git a/src/components/views/dialogs/devtools/RoomState.tsx b/src/components/views/dialogs/devtools/RoomState.tsx index 5bee4646632..ba8e3c75d9d 100644 --- a/src/components/views/dialogs/devtools/RoomState.tsx +++ b/src/components/views/dialogs/devtools/RoomState.tsx @@ -19,7 +19,7 @@ import React, { useContext, useEffect, useMemo, useState } from "react"; import { IContent, MatrixEvent } from "matrix-js-sdk/src/matrix"; import classNames from "classnames"; -import { _t } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { EventEditor, EventViewer, eventTypeField, stateKeyField, IEditorProps, stringify } from "./Event"; @@ -180,11 +180,11 @@ export const RoomStateExplorer: React.FC = ({ onBack, setTool }) } const onAction = async (): Promise => { - setTool(_t("devtools|send_custom_state_event"), StateEventEditor); + setTool(_td("devtools|send_custom_state_event"), StateEventEditor); }; return ( - + {Array.from(events.keys()).map((eventType) => ( setEventType(eventType)} /> diff --git a/src/components/views/dialogs/devtools/SettingExplorer.tsx b/src/components/views/dialogs/devtools/SettingExplorer.tsx index a7f930356f5..5e0a3929a83 100644 --- a/src/components/views/dialogs/devtools/SettingExplorer.tsx +++ b/src/components/views/dialogs/devtools/SettingExplorer.tsx @@ -18,7 +18,7 @@ limitations under the License. import React, { ChangeEvent, useContext, useMemo, useState } from "react"; import { logger } from "matrix-js-sdk/src/logger"; -import { _t } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import AccessibleButton from "../../elements/AccessibleButton"; import SettingsStore, { LEVEL_ORDER } from "../../../../settings/SettingsStore"; @@ -130,7 +130,7 @@ const EditSetting: React.FC = ({ setting, onBack }) => { }; return ( - +

{_t("devtools|setting_colon")} {setting}

@@ -207,7 +207,7 @@ const ViewSetting: React.FC = ({ setting, onEdit, onBack }) = const context = useContext(DevtoolsContext); return ( - +

{_t("devtools|setting_colon")} {setting}