From d115e3c7f8585a7832cba1cf75d6103a8475d8ff Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 11 Oct 2023 23:21:03 +0100 Subject: [PATCH] Fix untranslated headings in the devtools dialog (#11734) * Fix untranslated headings in the devtools dialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/DevtoolsDialog.tsx | 4 ++-- src/components/views/dialogs/devtools/AccountData.tsx | 8 ++++---- src/components/views/dialogs/devtools/BaseTool.tsx | 8 ++++---- src/components/views/dialogs/devtools/Event.tsx | 4 ++-- src/components/views/dialogs/devtools/RoomState.tsx | 6 +++--- src/components/views/dialogs/devtools/SettingExplorer.tsx | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.tsx b/src/components/views/dialogs/DevtoolsDialog.tsx index a2bcd0a8a2..f0f97e9ff8 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/AccountData.tsx b/src/components/views/dialogs/devtools/AccountData.tsx index 693ae0cd34..635becac3f 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 c6bd317624..49bcd76009 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 { @@ -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 d740b95b35..4b85dbe3f6 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 5bee464663..ba8e3c75d9 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 a7f930356f..5e0a3929a8 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}