Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Migrate more strings to translation keys (#11651)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Sep 22, 2023
1 parent 5604496 commit f4d056f
Show file tree
Hide file tree
Showing 127 changed files with 9,999 additions and 9,355 deletions.
41 changes: 18 additions & 23 deletions src/AddThreepid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import InteractiveAuthDialog, { InteractiveAuthDialogProps } from "./components/
function getIdServerDomain(matrixClient: MatrixClient): string {
const idBaseUrl = matrixClient.getIdentityServerUrl(true);
if (!idBaseUrl) {
throw new UserFriendlyError("Identity server not set");
throw new UserFriendlyError("settings|general|identity_server_not_set");
}
return idBaseUrl;
}
Expand Down Expand Up @@ -85,7 +85,7 @@ export default class AddThreepid {
return res;
} catch (err) {
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
throw new UserFriendlyError("This email address is already in use", { cause: err });
throw new UserFriendlyError("settings|general|email_address_in_use", { cause: err });
}
// Otherwise, just blurt out the same error
throw err;
Expand Down Expand Up @@ -115,7 +115,7 @@ export default class AddThreepid {
return res;
} catch (err) {
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
throw new UserFriendlyError("This email address is already in use", { cause: err });
throw new UserFriendlyError("settings|general|email_address_in_use", { cause: err });
}
// Otherwise, just blurt out the same error
throw err;
Expand All @@ -142,7 +142,7 @@ export default class AddThreepid {
return res;
} catch (err) {
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
throw new UserFriendlyError("This phone number is already in use", { cause: err });
throw new UserFriendlyError("settings|general|msisdn_in_use", { cause: err });
}
// Otherwise, just blurt out the same error
throw err;
Expand Down Expand Up @@ -174,7 +174,7 @@ export default class AddThreepid {
return res;
} catch (err) {
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
throw new UserFriendlyError("This phone number is already in use", { cause: err });
throw new UserFriendlyError("settings|general|msisdn_in_use", { cause: err });
}
// Otherwise, just blurt out the same error
throw err;
Expand All @@ -193,7 +193,7 @@ export default class AddThreepid {
const authClient = new IdentityAuthClient();
const identityAccessToken = await authClient.getAccessToken();
if (!identityAccessToken) {
throw new UserFriendlyError("No identity access token found");
throw new UserFriendlyError("settings|general|identity_server_no_token");
}
await this.matrixClient.bindThreePid({
sid: this.sessionId!,
Expand All @@ -216,22 +216,20 @@ export default class AddThreepid {

const dialogAesthetics = {
[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.",
),
title: _t("auth|uia|sso_title"),
body: _t("auth|uia|sso_body"),
continueText: _t("auth|sso"),
continueKind: "primary",
},
[SSOAuthEntry.PHASE_POSTAUTH]: {
title: _t("Confirm adding email"),
body: _t("Click the button below to confirm adding this email address."),
title: _t("settings|general|confirm_adding_email_title"),
body: _t("settings|general|confirm_adding_email_body"),
continueText: _t("action|confirm"),
continueKind: "primary",
},
};
const { finished } = Modal.createDialog(InteractiveAuthDialog<{}>, {
title: _t("Add Email Address"),
title: _t("settings|general|add_email_dialog_title"),
matrixClient: this.matrixClient,
authData: err.data,
makeRequest: this.makeAddThreepidOnlyRequest,
Expand All @@ -245,10 +243,7 @@ export default class AddThreepid {
}
} catch (err) {
if (err instanceof HTTPError && err.httpStatus === 401) {
throw new UserFriendlyError(
"Failed to verify email address: make sure you clicked the link in the email",
{ cause: err },
);
throw new UserFriendlyError("settings|general|add_email_failed_verification", { cause: err });
}
// Otherwise, just blurt out the same error
throw err;
Expand Down Expand Up @@ -296,7 +291,7 @@ export default class AddThreepid {
await authClient.getAccessToken(),
);
} else {
throw new UserFriendlyError("The add / bind with MSISDN flow is misconfigured");
throw new UserFriendlyError("settings|general|add_msisdn_misconfigured");
}

if (this.bind) {
Expand All @@ -321,20 +316,20 @@ export default class AddThreepid {

const dialogAesthetics = {
[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."),
title: _t("auth|uia|sso_title"),
body: _t("settings|general|add_msisdn_confirm_sso_button"),
continueText: _t("auth|sso"),
continueKind: "primary",
},
[SSOAuthEntry.PHASE_POSTAUTH]: {
title: _t("Confirm adding phone number"),
body: _t("Click the button below to confirm adding this phone number."),
title: _t("settings|general|add_msisdn_confirm_button"),
body: _t("settings|general|add_msisdn_confirm_body"),
continueText: _t("action|confirm"),
continueKind: "primary",
},
};
const { finished } = Modal.createDialog(InteractiveAuthDialog<{}>, {
title: _t("Add Phone Number"),
title: _t("settings|general|add_msisdn_dialog_title"),
matrixClient: this.matrixClient,
authData: err.data,
makeRequest: this.makeAddThreepidOnlyRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class AsyncWrapper extends React.Component<IProps, IState> {
} else if (this.state.error) {
return (
<BaseDialog onFinished={this.props.onFinished} title={_t("common|error")}>
{_t("Unable to load! Check your network connectivity and try again.")}
{_t("failed_load_async_component")}
<DialogButtons
primaryButton={_t("action|dismiss")}
onPrimaryButtonClick={this.onWrapperCancelClick}
Expand Down
6 changes: 3 additions & 3 deletions src/ContentMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,14 @@ export default class ContentMessages {
}

if (!upload.cancelled) {
let desc = _t("The file '%(fileName)s' failed to upload.", { fileName: upload.fileName });
let desc = _t("upload_failed_generic", { fileName: upload.fileName });
if (error instanceof HTTPError && error.httpStatus === 413) {
desc = _t("The file '%(fileName)s' exceeds this homeserver's size limit for uploads", {
desc = _t("upload_failed_size", {
fileName: upload.fileName,
});
}
Modal.createDialog(ErrorDialog, {
title: _t("Upload Failed"),
title: _t("upload_failed_title"),
description: desc,
});
dis.dispatch<UploadErrorPayload>({ action: Action.UploadFailed, upload, error });
Expand Down
6 changes: 3 additions & 3 deletions src/IdentityAuthClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ export default class IdentityAuthClient {
!(await doesIdentityServerHaveTerms(this.matrixClient, identityServerUrl))
) {
const { finished } = Modal.createDialog(QuestionDialog, {
title: _t("Identity server has no terms of service"),
title: _t("terms|identity_server_no_terms_title"),
description: (
<div>
<p>
{_t(
"This action requires accessing the default identity server <server /> to validate an email address or phone number, but the server does not have any terms of service.",
"terms|identity_server_no_terms_description_1",
{},
{
server: () => <b>{abbreviateUrl(identityServerUrl)}</b>,
},
)}
</p>
<p>{_t("Only continue if you trust the owner of the server.")}</p>
<p>{_t("terms|identity_server_no_terms_description_2")}</p>
</div>
),
button: _t("action|trust"),
Expand Down
58 changes: 28 additions & 30 deletions src/LegacyCallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ export default class LegacyCallHandler extends EventEmitter {
let description: string;
// TODO: We should either do away with these or figure out a copy for each code (expect user_hangup...)
if (call.hangupReason === CallErrorCode.UserBusy) {
title = _t("User Busy");
description = _t("The user you called is busy.");
title = _t("voip|user_busy");
description = _t("voip|user_busy_description");
} else {
title = _t("voip|call_failed");
description = _t("The call could not be established");
description = _t("voip|call_failed_description");
}

Modal.createDialog(ErrorDialog, {
Expand All @@ -718,8 +718,8 @@ export default class LegacyCallHandler extends EventEmitter {
});
} else if (hangupReason === CallErrorCode.AnsweredElsewhere && oldState === CallState.Connecting) {
Modal.createDialog(ErrorDialog, {
title: _t("Answered Elsewhere"),
description: _t("The call was answered on another device."),
title: _t("voip|answered_elsewhere"),
description: _t("voip|answered_elsewhere_description"),
});
} else if (oldState !== CallState.Fledgling && oldState !== CallState.Ringing) {
// don't play the end-call sound for calls that never got off the ground
Expand Down Expand Up @@ -818,26 +818,24 @@ export default class LegacyCallHandler extends EventEmitter {
Modal.createDialog(
QuestionDialog,
{
title: _t("Call failed due to misconfigured server"),
title: _t("voip|misconfigured_server"),
description: (
<div>
<p>
{_t(
"Please ask the administrator of your homeserver (<code>%(homeserverDomain)s</code>) to configure a TURN server in order for calls to work reliably.",
"voip|misconfigured_server_description",
{ homeserverDomain: cli.getDomain() },
{ code: (sub: string) => <code>{sub}</code> },
)}
</p>
<p>
{_t(
"Alternatively, you can try to use the public server at <server/>, but this will not be as reliable, and it will share your IP address with that server. You can also manage this in Settings.",
undefined,
{ server: () => <code>{new URL(FALLBACK_ICE_SERVER).pathname}</code> },
)}
{_t("voip|misconfigured_server_fallback", undefined, {
server: () => <code>{new URL(FALLBACK_ICE_SERVER).pathname}</code>,
})}
</p>
</div>
),
button: _t("Try using %(server)s", {
button: _t("voip|misconfigured_server_fallback_accept", {
server: new URL(FALLBACK_ICE_SERVER).pathname,
}),
cancelButton: _t("action|ok"),
Expand Down Expand Up @@ -958,17 +956,17 @@ export default class LegacyCallHandler extends EventEmitter {

if (cli.getSyncState() === SyncState.Error) {
Modal.createDialog(ErrorDialog, {
title: _t("Connectivity to the server has been lost"),
description: _t("You cannot place calls without a connection to the server."),
title: _t("voip|connection_lost"),
description: _t("voip|connection_lost_description"),
});
return;
}

// don't allow > 2 calls to be placed.
if (this.getAllActiveCalls().length > 1) {
Modal.createDialog(ErrorDialog, {
title: _t("Too Many Calls"),
description: _t("You've reached the maximum number of simultaneous calls."),
title: _t("voip|too_many_calls"),
description: _t("voip|too_many_calls_description"),
});
return;
}
Expand All @@ -985,7 +983,7 @@ export default class LegacyCallHandler extends EventEmitter {
const members = getJoinedNonFunctionalMembers(room);
if (members.length <= 1) {
Modal.createDialog(ErrorDialog, {
description: _t("You cannot place a call with yourself."),
description: _t("voip|cannot_call_yourself_description"),
});
} else if (members.length === 2) {
logger.info(`Place ${type} call in ${roomId}`);
Expand Down Expand Up @@ -1030,8 +1028,8 @@ export default class LegacyCallHandler extends EventEmitter {

if (this.getAllActiveCalls().length > 1) {
Modal.createDialog(ErrorDialog, {
title: _t("Too Many Calls"),
description: _t("You've reached the maximum number of simultaneous calls."),
title: _t("voip|too_many_calls"),
description: _t("voip|too_many_calls_description"),
});
return;
}
Expand All @@ -1055,8 +1053,8 @@ export default class LegacyCallHandler extends EventEmitter {
const results = await this.pstnLookup(number);
if (!results || results.length === 0 || !results[0].userid) {
Modal.createDialog(ErrorDialog, {
title: _t("Unable to look up phone number"),
description: _t("There was an error looking up the phone number"),
title: _t("voip|msisdn_lookup_failed"),
description: _t("voip|msisdn_lookup_failed_description"),
});
return;
}
Expand Down Expand Up @@ -1103,8 +1101,8 @@ export default class LegacyCallHandler extends EventEmitter {
const results = await this.pstnLookup(destination);
if (!results || results.length === 0 || !results[0].userid) {
Modal.createDialog(ErrorDialog, {
title: _t("Unable to transfer call"),
description: _t("There was an error looking up the phone number"),
title: _t("voip|msisdn_transfer_failed"),
description: _t("voip|msisdn_lookup_failed_description"),
});
return;
}
Expand All @@ -1118,8 +1116,8 @@ export default class LegacyCallHandler extends EventEmitter {
if (!dmRoomId) {
logger.log("Failed to transfer call, could not ensure dm exists");
Modal.createDialog(ErrorDialog, {
title: _t("Transfer Failed"),
description: _t("Failed to transfer call"),
title: _t("voip|transfer_failed"),
description: _t("voip|transfer_failed_description"),
});
return;
}
Expand All @@ -1138,8 +1136,8 @@ export default class LegacyCallHandler extends EventEmitter {
} catch (e) {
logger.log("Failed to transfer call", e);
Modal.createDialog(ErrorDialog, {
title: _t("Transfer Failed"),
description: _t("Failed to transfer call"),
title: _t("voip|transfer_failed"),
description: _t("voip|transfer_failed_description"),
});
}
}
Expand Down Expand Up @@ -1195,8 +1193,8 @@ export default class LegacyCallHandler extends EventEmitter {
} catch (e) {
if (e instanceof MatrixError && e.errcode === "M_FORBIDDEN") {
Modal.createDialog(ErrorDialog, {
title: _t("Permission Required"),
description: _t("You do not have permission to start a conference call in this room"),
title: _t("voip|no_permission_conference"),
description: _t("voip|no_permission_conference_description"),
});
}
logger.error(e);
Expand Down
Loading

0 comments on commit f4d056f

Please sign in to comment.