From 12dd799301c2633b3d780408d16166fb2b0fc5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Telaty=C5=84ski?= <7t3chguy@gmail.com> Date: Mon, 27 Feb 2023 09:15:27 +0000 Subject: [PATCH] Fix double translation issue (#10240 * Fix double translation issue * Remove some redundant string concatenations --- cypress/e2e/crypto/decryption-failure.spec.ts | 2 +- src/AddThreepid.ts | 5 ++--- src/LegacyCallHandler.tsx | 2 +- .../views/dialogs/eventindex/ManageEventIndexDialog.tsx | 8 +++----- src/components/structures/TimelinePanel.tsx | 4 +--- src/components/structures/auth/Login.tsx | 2 +- src/components/views/auth/CaptchaForm.tsx | 2 +- src/components/views/dialogs/StorageEvictedDialog.tsx | 2 +- .../views/dialogs/security/RestoreKeyBackupDialog.tsx | 4 ++-- src/components/views/location/LocationPicker.tsx | 2 +- src/components/views/rooms/NewRoomIntro.tsx | 6 +++--- src/components/views/rooms/RoomPreviewBar.tsx | 2 +- src/components/views/settings/EventIndexPanel.tsx | 2 +- src/components/views/settings/SecureBackupPanel.tsx | 2 +- src/components/views/settings/SetIdServer.tsx | 4 ++-- src/components/views/settings/account/EmailAddresses.tsx | 2 +- .../views/settings/discovery/EmailAddresses.tsx | 2 +- src/utils/leave-behaviour.ts | 4 ++-- src/utils/location/findMapStyleUrl.ts | 4 +--- src/utils/location/map.ts | 5 +---- test/components/views/elements/EventListSummary-test.tsx | 4 +--- 21 files changed, 29 insertions(+), 41 deletions(-) diff --git a/cypress/e2e/crypto/decryption-failure.spec.ts b/cypress/e2e/crypto/decryption-failure.spec.ts index 20f748494a..15b437d621 100644 --- a/cypress/e2e/crypto/decryption-failure.spec.ts +++ b/cypress/e2e/crypto/decryption-failure.spec.ts @@ -164,7 +164,7 @@ describe("Decryption Failure Bar", () => { cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist"); cy.get(".mx_DecryptionFailureBar").percySnapshotElement( - "DecryptionFailureBar prompts user to open another device, " + "without Resend Key Requests button", + "DecryptionFailureBar prompts user to open another device, without Resend Key Requests button", { widths: [320, 640], }, diff --git a/src/AddThreepid.ts b/src/AddThreepid.ts index b1ee5795d0..db74eaad31 100644 --- a/src/AddThreepid.ts +++ b/src/AddThreepid.ts @@ -213,8 +213,7 @@ export default class AddThreepid { [SSOAuthEntry.PHASE_PREAUTH]: { title: _t("Use Single Sign On to continue"), body: _t( - "Confirm adding this email address by using " + - "Single Sign On to prove your identity.", + "Confirm adding this email address by using Single Sign On to prove your identity.", ), continueText: _t("Single Sign On"), continueKind: "primary", @@ -333,7 +332,7 @@ export default class AddThreepid { [SSOAuthEntry.PHASE_PREAUTH]: { title: _t("Use Single Sign On to continue"), body: _t( - "Confirm adding this phone number by using " + "Single Sign On to prove your identity.", + "Confirm adding this phone number by using Single Sign On to prove your identity.", ), continueText: _t("Single Sign On"), continueKind: "primary", diff --git a/src/LegacyCallHandler.tsx b/src/LegacyCallHandler.tsx index b5358b4930..90bded231e 100644 --- a/src/LegacyCallHandler.tsx +++ b/src/LegacyCallHandler.tsx @@ -737,7 +737,7 @@ export default class LegacyCallHandler extends EventEmitter { ); if (!stats) { logger.debug( - "Call statistics are undefined. The call has " + "probably failed before a peerConn was established", + "Call statistics are undefined. The call has probably failed before a peerConn was established", ); return; } diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx index 5393ae3fc6..5513165e69 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx @@ -157,11 +157,9 @@ export default class ManageEventIndexDialog extends React.Component - {_t( - "%(brand)s is securely caching encrypted messages locally for them " + - "to appear in search results:", - { brand }, - )} + {_t("%(brand)s is securely caching encrypted messages locally for them to appear in search results:", { + brand, + })}
{crawlerState}
diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index da17ae36e1..8e6833954f 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -1473,9 +1473,7 @@ class TimelinePanel extends React.Component { "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.", - ); + description = _t("Tried to load a specific point in this room's timeline, but was unable to find it."); } Modal.createDialog(ErrorDialog, { diff --git a/src/components/structures/auth/Login.tsx b/src/components/structures/auth/Login.tsx index c2c7a0d913..97f3866f96 100644 --- a/src/components/structures/auth/Login.tsx +++ b/src/components/structures/auth/Login.tsx @@ -454,7 +454,7 @@ export default class LoginComponent extends React.PureComponent } let errorText: ReactNode = - _t("There was a problem communicating with the homeserver, " + "please try again later.") + + _t("There was a problem communicating with the homeserver, please try again later.") + (errCode ? " (" + errCode + ")" : ""); if (err instanceof ConnectionError) { diff --git a/src/components/views/auth/CaptchaForm.tsx b/src/components/views/auth/CaptchaForm.tsx index 651921b233..a34038f000 100644 --- a/src/components/views/auth/CaptchaForm.tsx +++ b/src/components/views/auth/CaptchaForm.tsx @@ -91,7 +91,7 @@ export default class CaptchaForm extends React.Component { )}

- {_t("Your browser likely removed this data when running low on " + "disk space.")} {logRequest} + {_t("Your browser likely removed this data when running low on disk space.")} {logRequest}

{_t( - "Warning: you should only set up key backup " + "from a trusted computer.", + "Warning: you should only set up key backup from a trusted computer.", {}, { b: (sub) => {sub} }, )} @@ -480,7 +480,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent

{_t( - "Warning: you should only set up key backup " + "from a trusted computer.", + "Warning: you should only set up key backup from a trusted computer.", {}, { b: (sub) => {sub} }, )} diff --git a/src/components/views/location/LocationPicker.tsx b/src/components/views/location/LocationPicker.tsx index 53c010c809..503d4d8688 100644 --- a/src/components/views/location/LocationPicker.tsx +++ b/src/components/views/location/LocationPicker.tsx @@ -93,7 +93,7 @@ class LocationPicker extends React.Component { this.map.on("error", (e) => { logger.error( - "Failed to load map: check map_style_url in config.json " + "has a valid URL and API key", + "Failed to load map: check map_style_url in config.json has a valid URL and API key", e.error, ); this.setState({ error: LocationShareError.MapStyleUrlNotReachable }); diff --git a/src/components/views/rooms/NewRoomIntro.tsx b/src/components/views/rooms/NewRoomIntro.tsx index fba24be3f2..f8ab6f4c18 100644 --- a/src/components/views/rooms/NewRoomIntro.tsx +++ b/src/components/views/rooms/NewRoomIntro.tsx @@ -23,7 +23,7 @@ import { User } from "matrix-js-sdk/src/models/user"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import RoomContext from "../../../contexts/RoomContext"; import DMRoomMap from "../../../utils/DMRoomMap"; -import { _t } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton"; import MiniAvatarUploader, { AVATAR_SIZE } from "../elements/MiniAvatarUploader"; import RoomAvatar from "../avatars/RoomAvatar"; @@ -55,11 +55,11 @@ const NewRoomIntro: React.FC = () => { let body: JSX.Element; if (dmPartner) { - let introMessage = _t("This is the beginning of your direct message history with ."); + let introMessage = _td("This is the beginning of your direct message history with ."); let caption: string | undefined; if (isLocalRoom) { - introMessage = _t("Send your first message to invite to chat"); + introMessage = _td("Send your first message to invite to chat"); } else if (room.getJoinedMemberCount() + room.getInvitedMemberCount() === 2) { caption = _t("Only the two of you are in this conversation, unless either of you invites anyone to join."); } diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index f9359bc5a5..a968bd3794 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -435,7 +435,7 @@ export default class RoomPreviewBar extends React.Component { } subTitle = _t( - "Link this email with your account in Settings to receive invites " + "directly in %(brand)s.", + "Link this email with your account in Settings to receive invites directly in %(brand)s.", { brand }, ); primaryActionLabel = _t("Join the discussion"); diff --git a/src/components/views/settings/EventIndexPanel.tsx b/src/components/views/settings/EventIndexPanel.tsx index c5e617355d..8a1d93c98f 100644 --- a/src/components/views/settings/EventIndexPanel.tsx +++ b/src/components/views/settings/EventIndexPanel.tsx @@ -177,7 +177,7 @@ export default class EventIndexPanel extends React.Component<{}, IState> { eventIndexingSettings = (

- {_t("Securely cache encrypted messages locally for them to " + "appear in search results.")} + {_t("Securely cache encrypted messages locally for them to appear in search results.")}
diff --git a/src/components/views/settings/SecureBackupPanel.tsx b/src/components/views/settings/SecureBackupPanel.tsx index cc5dde1cb0..98c241fd0f 100644 --- a/src/components/views/settings/SecureBackupPanel.tsx +++ b/src/components/views/settings/SecureBackupPanel.tsx @@ -183,7 +183,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> { Modal.createDialog(QuestionDialog, { title: _t("Delete Backup"), description: _t( - "Are you sure? You will lose your encrypted messages if your " + "keys are not backed up properly.", + "Are you sure? You will lose your encrypted messages if your keys are not backed up properly.", ), button: _t("Delete Backup"), danger: true, diff --git a/src/components/views/settings/SetIdServer.tsx b/src/components/views/settings/SetIdServer.tsx index 43f59c8ee1..feb1bc0f79 100644 --- a/src/components/views/settings/SetIdServer.tsx +++ b/src/components/views/settings/SetIdServer.tsx @@ -192,7 +192,7 @@ export default class SetIdServer extends React.Component { const [confirmed] = await this.showServerChangeWarning({ title: _t("Change identity server"), unboundMessage: _t( - "Disconnect from the identity server and " + "connect to instead?", + "Disconnect from the identity server and connect to instead?", {}, { current: (sub) => {abbreviateUrl(currentClientIdServer)}, @@ -330,7 +330,7 @@ export default class SetIdServer extends React.Component {

{_t( - "You are still sharing your personal data on the identity " + "server .", + "You are still sharing your personal data on the identity server .", {}, messageElements, )} diff --git a/src/components/views/settings/account/EmailAddresses.tsx b/src/components/views/settings/account/EmailAddresses.tsx index 83e137a21a..0d5405d93f 100644 --- a/src/components/views/settings/account/EmailAddresses.tsx +++ b/src/components/views/settings/account/EmailAddresses.tsx @@ -223,7 +223,7 @@ export default class EmailAddresses extends React.Component { Modal.createDialog(ErrorDialog, { title: _t("Your email address hasn't been verified yet"), description: _t( - "Click the link in the email you received to verify " + "and then click continue again.", + "Click the link in the email you received to verify and then click continue again.", ), }); } else { diff --git a/src/components/views/settings/discovery/EmailAddresses.tsx b/src/components/views/settings/discovery/EmailAddresses.tsx index 9f2e123ac3..18cf49a162 100644 --- a/src/components/views/settings/discovery/EmailAddresses.tsx +++ b/src/components/views/settings/discovery/EmailAddresses.tsx @@ -184,7 +184,7 @@ export class EmailAddress extends React.Component !!r[1]); if (errors.length > 0) { - const messages = []; + const messages: ReactNode[] = []; for (const roomErr of errors) { const err = roomErr[1]; // [0] is the roomId let message = _t("Unexpected server error trying to leave the room"); diff --git a/src/utils/location/findMapStyleUrl.ts b/src/utils/location/findMapStyleUrl.ts index 0653d65cf2..02ff401b14 100644 --- a/src/utils/location/findMapStyleUrl.ts +++ b/src/utils/location/findMapStyleUrl.ts @@ -29,9 +29,7 @@ export function findMapStyleUrl(): string { const mapStyleUrl = getTileServerWellKnown()?.map_style_url ?? SdkConfig.get().map_style_url; if (!mapStyleUrl) { - logger.error( - "'map_style_url' missing from homeserver .well-known area, and " + "missing from from config.json.", - ); + logger.error("'map_style_url' missing from homeserver .well-known area, and missing from from config.json."); throw new Error(LocationShareError.MapStyleUrlNotConfigured); } diff --git a/src/utils/location/map.ts b/src/utils/location/map.ts index 34d3d01478..b0434d76cd 100644 --- a/src/utils/location/map.ts +++ b/src/utils/location/map.ts @@ -50,10 +50,7 @@ export const createMap = (interactive: boolean, bodyId: string, onError?: (error map.addControl(new maplibregl.AttributionControl(), "top-right"); map.on("error", (e) => { - logger.error( - "Failed to load map: check map_style_url in config.json has a " + "valid URL and API key", - e.error, - ); + logger.error("Failed to load map: check map_style_url in config.json has a valid URL and API key", e.error); onError?.(new Error(LocationShareError.MapStyleUrlNotReachable)); }); diff --git a/test/components/views/elements/EventListSummary-test.tsx b/test/components/views/elements/EventListSummary-test.tsx index 4ecb963ee0..81fc59e2aa 100644 --- a/test/components/views/elements/EventListSummary-test.tsx +++ b/test/components/views/elements/EventListSummary-test.tsx @@ -567,9 +567,7 @@ describe("EventListSummary", function () { const summary = wrapper.find(".mx_GenericEventListSummary_summary"); const summaryText = summary.text(); - expect(summaryText).toBe( - "user_1 and one other rejected their invitations and " + "had their invitations withdrawn", - ); + expect(summaryText).toBe("user_1 and one other rejected their invitations and had their invitations withdrawn"); }); it("handles invitation plurals correctly when there are multiple invites", function () {