Fix instances of double translation and guard translation calls using typescript (#11443)

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Michael Telatynski 2023-08-22 16:32:05 +01:00 committed by GitHub
parent d13b6e1b41
commit ac70f7ac9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
157 changed files with 554 additions and 780 deletions

View file

@ -21,7 +21,7 @@ import sanitizeHtml from "sanitize-html";
import classnames from "classnames";
import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../languageHandler";
import { _t, TranslationKey } from "../../languageHandler";
import dis from "../../dispatcher/dispatcher";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import MatrixClientContext from "../../contexts/MatrixClientContext";
@ -56,7 +56,7 @@ export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
};
}
private translate(s: string): string {
private translate(s: TranslationKey): string {
return sanitizeHtml(_t(s));
}

View file

@ -482,12 +482,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
const waitText = _t("Wait!");
const scamText = _t(
"If someone told you to copy/paste something here, " + "there is a high likelihood you're being scammed!",
"If someone told you to copy/paste something here, there is a high likelihood you're being scammed!",
);
const devText = _t(
"If you know what you're doing, Element is open-source, " +
"be sure to check out our GitHub (https://github.com/vector-im/element-web/) " +
"and contribute!",
"If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!",
);
global.mx_rage_logger.bypassRageshake(
@ -1166,8 +1164,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
<span className="warning" key="only_member_warning">
{" " /* Whitespace, otherwise the sentences get smashed together */}
{_t(
"You are the only person here. " +
"If you leave, no one will be able to join in the future, including you.",
"You are the only person here. If you leave, no one will be able to join in the future, including you.",
)}
</span>,
);
@ -1593,8 +1590,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
<p>
{" "}
{_t(
"To continue using the %(homeserverDomain)s homeserver " +
"you must review and agree to our terms and conditions.",
"To continue using the %(homeserverDomain)s homeserver you must review and agree to our terms and conditions.",
{ homeserverDomain: cli.getDomain() },
)}
</p>
@ -1643,13 +1639,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
Modal.createDialog(ErrorDialog, {
title: _t("Old cryptography data detected"),
description: _t(
"Data from an older version of %(brand)s has been detected. " +
"This will have caused end-to-end cryptography to malfunction " +
"in the older version. End-to-end encrypted messages exchanged " +
"recently whilst using the older version may not be decryptable " +
"in this version. This may also cause messages exchanged with this " +
"version to fail. If you experience problems, log out and back in " +
"again. To retain message history, export and re-import your keys.",
"Data from an older version of %(brand)s has been detected. This will have caused end-to-end cryptography to malfunction in the older version. End-to-end encrypted messages exchanged recently whilst using the older version may not be decryptable in this version. This may also cause messages exchanged with this version to fail. If you experience problems, log out and back in again. To retain message history, export and re-import your keys.",
{ brand: SdkConfig.get().brand },
),
});

View file

@ -207,8 +207,7 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
}
if (consentError) {
title = _t(
"You can't send any messages until you review and agree to " +
"<consentLink>our terms and conditions</consentLink>.",
"You can't send any messages until you review and agree to <consentLink>our terms and conditions</consentLink>.",
{},
{
consentLink: (sub) => (
@ -224,16 +223,13 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
resourceLimitError.data.admin_contact,
{
"monthly_active_user": _td(
"Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. " +
"Please <a>contact your service administrator</a> to continue using the service.",
"Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. Please <a>contact your service administrator</a> to continue using the service.",
),
"hs_disabled": _td(
"Your message wasn't sent because this homeserver has been blocked by its administrator. " +
"Please <a>contact your service administrator</a> to continue using the service.",
"Your message wasn't sent because this homeserver has been blocked by its administrator. Please <a>contact your service administrator</a> to continue using the service.",
),
"": _td(
"Your message wasn't sent because this homeserver has exceeded a resource limit. " +
"Please <a>contact your service administrator</a> to continue using the service.",
"Your message wasn't sent because this homeserver has exceeded a resource limit. Please <a>contact your service administrator</a> to continue using the service.",
),
},
);

View file

@ -401,8 +401,7 @@ const SpaceAddExistingRooms: React.FC<{
<h1>{_t("What do you want to organise?")}</h1>
<div className="mx_SpaceRoomView_description">
{_t(
"Pick rooms or conversations to add. This is just a space for you, " +
"no one will be informed. You can add more later.",
"Pick rooms or conversations to add. This is just a space for you, no one will be informed. You can add more later.",
)}
</div>

View file

@ -20,7 +20,7 @@ import * as React from "react";
import classNames from "classnames";
import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../languageHandler";
import { _t, TranslationKey } from "../../languageHandler";
import AutoHideScrollbar from "./AutoHideScrollbar";
import { PosthogScreenTracker, ScreenName } from "../../PosthogTrackers";
import { NonEmptyArray } from "../../@types/common";
@ -40,7 +40,7 @@ export class Tab<T extends string> {
*/
public constructor(
public readonly id: T,
public readonly label: string,
public readonly label: TranslationKey,
public readonly icon: string | null,
public readonly body: React.ReactNode,
public readonly screenName?: ScreenName,

View file

@ -147,8 +147,7 @@ const EmptyThread: React.FC<EmptyThreadIProps> = ({ hasThreads, filterOption, sh
<>
<p>
{_t(
"Reply to an ongoing thread or use “%(replyInThread)s” " +
"when hovering over a message to start a new one.",
"Reply to an ongoing thread or use “%(replyInThread)s” when hovering over a message to start a new one.",
{
replyInThread: _t("Reply in thread"),
},

View file

@ -1651,8 +1651,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
let description: string;
if (error.errcode == "M_FORBIDDEN") {
description = _t(
"Tried to load a specific point in this room's timeline, but you " +
"do not have permission to view the message in question.",
"Tried to load a specific point in this room's timeline, but you do not have permission to view the message in question.",
);
} else {
description = _t("Tried to load a specific point in this room's timeline, but was unable to find it.");

View file

@ -75,8 +75,7 @@ export const WaitingForThirdPartyRoomView: React.FC<Props> = ({ roomView, resize
className="mx_cryptoEvent mx_cryptoEvent_icon"
title={_t("Waiting for users to join %(brand)s", { brand })}
subtitle={_t(
"Once invited users have joined %(brand)s, " +
"you will be able to chat and the room will be end-to-end encrypted",
"Once invited users have joined %(brand)s, you will be able to chat and the room will be end-to-end encrypted",
{ brand },
)}
/>

View file

@ -354,14 +354,12 @@ export default class ForgotPassword extends React.Component<Props, State> {
<div>
<p>
{_t(
"Signing out your devices will delete the message encryption keys stored on them, " +
"making encrypted chat history unreadable.",
"Signing out your devices will delete the message encryption keys stored on them, making encrypted chat history unreadable.",
)}
</p>
<p>
{_t(
"If you want to retain access to your chat history in encrypted rooms, set up Key Backup " +
"or export your message keys from one of your other devices before proceeding.",
"If you want to retain access to your chat history in encrypted rooms, set up Key Backup or export your message keys from one of your other devices before proceeding.",
)}
</p>
</div>
@ -443,9 +441,7 @@ export default class ForgotPassword extends React.Component<Props, State> {
{this.state.logoutDevices ? (
<p>
{_t(
"You have been logged out of all devices and will no longer receive " +
"push notifications. To re-enable notifications, sign in again on each " +
"device.",
"You have been logged out of all devices and will no longer receive push notifications. To re-enable notifications, sign in again on each device.",
)}
</p>
) : null}

View file

@ -622,8 +622,7 @@ export default class Registration extends React.Component<IProps, IState> {
<div>
<p>
{_t(
"Your new account (%(newAccountId)s) is registered, but you're already " +
"logged into a different account (%(loggedInUserId)s).",
"Your new account (%(newAccountId)s) is registered, but you're already logged into a different account (%(loggedInUserId)s).",
{
newAccountId: this.state.registeredUsername,
loggedInUserId: this.state.differentLoggedInUserId,

View file

@ -161,10 +161,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
<div>
<p>
{_t(
"It looks like you don't have a Security Key or any other devices you can " +
"verify against. This device will not be able to access old encrypted messages. " +
"In order to verify your identity on this device, you'll need to reset " +
"your verification keys.",
"It looks like you don't have a Security Key or any other devices you can verify against. This device will not be able to access old encrypted messages. In order to verify your identity on this device, you'll need to reset your verification keys.",
)}
</p>
@ -234,8 +231,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
message = (
<p>
{_t(
"Your new device is now verified. It has access to your " +
"encrypted messages, and other users will see it as trusted.",
"Your new device is now verified. It has access to your encrypted messages, and other users will see it as trusted.",
)}
</p>
);
@ -258,8 +254,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
<div>
<p>
{_t(
"Without verifying, you won't have access to all your messages " +
"and may appear as untrusted to others.",
"Without verifying, you won't have access to all your messages and may appear as untrusted to others.",
)}
</p>
<div className="mx_CompleteSecurity_actionRow">
@ -277,16 +272,12 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
<div>
<p>
{_t(
"Resetting your verification keys cannot be undone. After resetting, " +
"you won't have access to old encrypted messages, and any friends who " +
"have previously verified you will see security warnings until you " +
"re-verify with them.",
"Resetting your verification keys cannot be undone. After resetting, you won't have access to old encrypted messages, and any friends who have previously verified you will see security warnings until you re-verify with them.",
)}
</p>
<p>
{_t(
"Please only proceed if you're sure you've lost all of your other " +
"devices and your Security Key.",
"Please only proceed if you're sure you've lost all of your other devices and your Security Key.",
)}
</p>

View file

@ -281,8 +281,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
let introText: string | null = null; // null is translated to something area specific in this function
if (this.state.keyBackupNeeded) {
introText = _t(
"Regain access to your account and recover encryption keys stored in this session. " +
"Without them, you won't be able to read all of your secure messages in any session.",
"Regain access to your account and recover encryption keys stored in this session. Without them, you won't be able to read all of your secure messages in any session.",
);
}
@ -329,10 +328,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
// Default: assume unsupported/error
return (
<p>
{_t(
"You cannot sign in to your account. Please contact your " +
"homeserver admin for more information.",
)}
{_t("You cannot sign in to your account. Please contact your homeserver admin for more information.")}
</p>
);
}
@ -350,9 +346,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
<h2>{_t("Clear personal data")}</h2>
<p>
{_t(
"Warning: your personal data (including encryption keys) is still stored " +
"in this session. Clear it if you're finished using this session, or want to sign " +
"in to another account.",
"Warning: your personal data (including encryption keys) is still stored in this session. Clear it if you're finished using this session, or want to sign in to another account.",
)}
</p>
<div>

View file

@ -54,8 +54,7 @@ export const VerifyEmailModal: React.FC<Props> = ({
<h1>{_t("Verify your email to continue")}</h1>
<p>
{_t(
"We need to know its you before resetting your password. " +
"Click the link in the email we just sent to <b>%(email)s</b>",
"We need to know its you before resetting your password. Click the link in the email we just sent to <b>%(email)s</b>",
{
email,
},