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>
This commit is contained in:
Michael Telatynski 2023-10-11 23:21:03 +01:00 committed by GitHub
parent 5d169afb8a
commit d115e3c7f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 18 deletions

View file

@ -69,7 +69,7 @@ interface IProps {
onFinished(finished?: boolean): void; onFinished(finished?: boolean): void;
} }
type ToolInfo = [label: string, tool: Tool]; type ToolInfo = [label: TranslationKey, tool: Tool];
const DevtoolsDialog: React.FC<IProps> = ({ roomId, threadRootId, onFinished }) => { const DevtoolsDialog: React.FC<IProps> = ({ roomId, threadRootId, onFinished }) => {
const [tool, setTool] = useState<ToolInfo | null>(null); const [tool, setTool] = useState<ToolInfo | null>(null);
@ -116,7 +116,7 @@ const DevtoolsDialog: React.FC<IProps> = ({ roomId, threadRootId, onFinished })
); );
} }
const label = tool ? tool[0] : _t("devtools|toolbox"); const label = tool ? _t(tool[0]) : _t("devtools|toolbox");
return ( return (
<BaseDialog className="mx_QuestionDialog" onFinished={onFinished} title={_t("devtools|developer_tools")}> <BaseDialog className="mx_QuestionDialog" onFinished={onFinished} title={_t("devtools|developer_tools")}>
<MatrixClientContext.Consumer> <MatrixClientContext.Consumer>

View file

@ -22,7 +22,7 @@ import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import MatrixClientContext from "../../../../contexts/MatrixClientContext";
import { EventEditor, EventViewer, eventTypeField, IEditorProps, stringify } from "./Event"; import { EventEditor, EventViewer, eventTypeField, IEditorProps, stringify } from "./Event";
import FilteredList from "./FilteredList"; import FilteredList from "./FilteredList";
import { _t } from "../../../../languageHandler"; import { _td, TranslationKey } from "../../../../languageHandler";
export const AccountDataEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => { export const AccountDataEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
@ -54,7 +54,7 @@ export const RoomAccountDataEventEditor: React.FC<IEditorProps> = ({ mxEvent, on
interface IProps extends IDevtoolsProps { interface IProps extends IDevtoolsProps {
events: Map<string, MatrixEvent>; events: Map<string, MatrixEvent>;
Editor: React.FC<IEditorProps>; Editor: React.FC<IEditorProps>;
actionLabel: string; actionLabel: TranslationKey;
} }
const BaseAccountDataExplorer: React.FC<IProps> = ({ events, Editor, actionLabel, onBack, setTool }) => { const BaseAccountDataExplorer: React.FC<IProps> = ({ events, Editor, actionLabel, onBack, setTool }) => {
@ -98,7 +98,7 @@ export const AccountDataExplorer: React.FC<IDevtoolsProps> = ({ onBack, setTool
<BaseAccountDataExplorer <BaseAccountDataExplorer
events={cli.store.accountData} events={cli.store.accountData}
Editor={AccountDataEventEditor} Editor={AccountDataEventEditor}
actionLabel={_t("devtools|send_custom_account_data_event")} actionLabel={_td("devtools|send_custom_account_data_event")}
onBack={onBack} onBack={onBack}
setTool={setTool} setTool={setTool}
/> />
@ -112,7 +112,7 @@ export const RoomAccountDataExplorer: React.FC<IDevtoolsProps> = ({ onBack, setT
<BaseAccountDataExplorer <BaseAccountDataExplorer
events={context.room.accountData} events={context.room.accountData}
Editor={RoomAccountDataEventEditor} Editor={RoomAccountDataEventEditor}
actionLabel={_t("devtools|send_custom_room_account_data_event")} actionLabel={_td("devtools|send_custom_room_account_data_event")}
onBack={onBack} onBack={onBack}
setTool={setTool} setTool={setTool}
/> />

View file

@ -19,13 +19,13 @@ import React, { createContext, ReactNode, useState } from "react";
import { Room } from "matrix-js-sdk/src/matrix"; import { Room } from "matrix-js-sdk/src/matrix";
import classNames from "classnames"; import classNames from "classnames";
import { _t } from "../../../../languageHandler"; import { _t, TranslationKey } from "../../../../languageHandler";
import { XOR } from "../../../../@types/common"; import { XOR } from "../../../../@types/common";
import { Tool } from "../DevtoolsDialog"; import { Tool } from "../DevtoolsDialog";
export interface IDevtoolsProps { export interface IDevtoolsProps {
onBack(): void; onBack(): void;
setTool(label: string, tool: Tool): void; setTool(label: TranslationKey, tool: Tool): void;
} }
interface IMinProps extends Pick<IDevtoolsProps, "onBack"> { interface IMinProps extends Pick<IDevtoolsProps, "onBack"> {
@ -35,7 +35,7 @@ interface IMinProps extends Pick<IDevtoolsProps, "onBack"> {
} }
interface IProps extends IMinProps { interface IProps extends IMinProps {
actionLabel: string; actionLabel: TranslationKey;
onAction(): Promise<string | void>; onAction(): Promise<string | void>;
} }
@ -69,7 +69,7 @@ const BaseTool: React.FC<XOR<IMinProps, IProps>> = ({
}); });
}; };
actionButton = <button onClick={onActionClick}>{actionLabel}</button>; actionButton = <button onClick={onActionClick}>{_t(actionLabel)}</button>;
} }
return ( return (

View file

@ -117,7 +117,7 @@ export const EventEditor: React.FC<IEventEditorProps> = ({ fieldDefs, defaultCon
}; };
return ( return (
<BaseTool actionLabel={_t("forward|send_label")} onAction={onAction} onBack={onBack}> <BaseTool actionLabel={_td("forward|send_label")} onAction={onAction} onBack={onBack}>
<div className="mx_DevTools_eventTypeStateKeyGroup">{fields}</div> <div className="mx_DevTools_eventTypeStateKeyGroup">{fields}</div>
<Field <Field
@ -161,7 +161,7 @@ export const EventViewer: React.FC<IViewerProps> = ({ mxEvent, onBack, Editor, e
}; };
return ( return (
<BaseTool onBack={onBack} actionLabel={_t("action|edit")} onAction={onAction} extraButton={extraButton}> <BaseTool onBack={onBack} actionLabel={_td("action|edit")} onAction={onAction} extraButton={extraButton}>
<SyntaxHighlight language="json">{stringify(mxEvent.event)}</SyntaxHighlight> <SyntaxHighlight language="json">{stringify(mxEvent.event)}</SyntaxHighlight>
</BaseTool> </BaseTool>
); );

View file

@ -19,7 +19,7 @@ import React, { useContext, useEffect, useMemo, useState } from "react";
import { IContent, MatrixEvent } from "matrix-js-sdk/src/matrix"; import { IContent, MatrixEvent } from "matrix-js-sdk/src/matrix";
import classNames from "classnames"; import classNames from "classnames";
import { _t } from "../../../../languageHandler"; import { _t, _td } from "../../../../languageHandler";
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import MatrixClientContext from "../../../../contexts/MatrixClientContext";
import { EventEditor, EventViewer, eventTypeField, stateKeyField, IEditorProps, stringify } from "./Event"; import { EventEditor, EventViewer, eventTypeField, stateKeyField, IEditorProps, stringify } from "./Event";
@ -180,11 +180,11 @@ export const RoomStateExplorer: React.FC<IDevtoolsProps> = ({ onBack, setTool })
} }
const onAction = async (): Promise<void> => { const onAction = async (): Promise<void> => {
setTool(_t("devtools|send_custom_state_event"), StateEventEditor); setTool(_td("devtools|send_custom_state_event"), StateEventEditor);
}; };
return ( return (
<BaseTool onBack={onBack} actionLabel={_t("devtools|send_custom_state_event")} onAction={onAction}> <BaseTool onBack={onBack} actionLabel={_td("devtools|send_custom_state_event")} onAction={onAction}>
<FilteredList query={query} onChange={setQuery}> <FilteredList query={query} onChange={setQuery}>
{Array.from(events.keys()).map((eventType) => ( {Array.from(events.keys()).map((eventType) => (
<StateEventButton key={eventType} label={eventType} onClick={() => setEventType(eventType)} /> <StateEventButton key={eventType} label={eventType} onClick={() => setEventType(eventType)} />

View file

@ -18,7 +18,7 @@ limitations under the License.
import React, { ChangeEvent, useContext, useMemo, useState } from "react"; import React, { ChangeEvent, useContext, useMemo, useState } from "react";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../../../languageHandler"; import { _t, _td } from "../../../../languageHandler";
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
import AccessibleButton from "../../elements/AccessibleButton"; import AccessibleButton from "../../elements/AccessibleButton";
import SettingsStore, { LEVEL_ORDER } from "../../../../settings/SettingsStore"; import SettingsStore, { LEVEL_ORDER } from "../../../../settings/SettingsStore";
@ -130,7 +130,7 @@ const EditSetting: React.FC<IEditSettingProps> = ({ setting, onBack }) => {
}; };
return ( return (
<BaseTool onBack={onBack} actionLabel={_t("devtools|save_setting_values")} onAction={onSave}> <BaseTool onBack={onBack} actionLabel={_td("devtools|save_setting_values")} onAction={onSave}>
<h3> <h3>
{_t("devtools|setting_colon")} <code>{setting}</code> {_t("devtools|setting_colon")} <code>{setting}</code>
</h3> </h3>
@ -207,7 +207,7 @@ const ViewSetting: React.FC<IViewSettingProps> = ({ setting, onEdit, onBack }) =
const context = useContext(DevtoolsContext); const context = useContext(DevtoolsContext);
return ( return (
<BaseTool onBack={onBack} actionLabel={_t("devtools|edit_values")} onAction={onEdit}> <BaseTool onBack={onBack} actionLabel={_td("devtools|edit_values")} onAction={onEdit}>
<h3> <h3>
{_t("devtools|setting_colon")} <code>{setting}</code> {_t("devtools|setting_colon")} <code>{setting}</code>
</h3> </h3>