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 (#11608)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Sep 19, 2023
1 parent 46072ca commit e9c9377
Show file tree
Hide file tree
Showing 78 changed files with 2,402 additions and 2,411 deletions.
8 changes: 4 additions & 4 deletions src/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export async function startAnyRegistrationFlow(
const modal = Modal.createDialog(QuestionDialog, {
hasCancelButton: true,
quitOnly: true,
title: SettingsStore.getValue(UIFeature.Registration) ? _t("Sign In or Create Account") : _t("action|sign_in"),
title: SettingsStore.getValue(UIFeature.Registration) ? _t("auth|sign_in_or_register") : _t("action|sign_in"),
description: SettingsStore.getValue(UIFeature.Registration)
? _t("Use your account or create a new one to continue.")
: _t("Use your account to continue."),
? _t("auth|sign_in_or_register_description")
: _t("auth|sign_in_description"),
button: _t("action|sign_in"),
extraButtons: SettingsStore.getValue(UIFeature.Registration)
? [
Expand All @@ -67,7 +67,7 @@ export async function startAnyRegistrationFlow(
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
}}
>
{_t("Create Account")}
{_t("auth|register_action")}
</button>,
]
: [],
Expand Down
6 changes: 3 additions & 3 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
topSection = (
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
{_t(
"Got an account? <a>Sign in</a>",
"auth|sign_in_prompt",
{},
{
a: (sub) => (
Expand All @@ -307,7 +307,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
)}
{SettingsStore.getValue(UIFeature.Registration)
? _t(
"New here? <a>Create an account</a>",
"auth|create_account_prompt",
{},
{
a: (sub) => (
Expand Down Expand Up @@ -338,7 +338,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
feedbackButton = (
<IconizedContextMenuOption
iconClassName="mx_UserMenu_iconMessage"
label={_t("Feedback")}
label={_t("common|feedback")}
onClick={this.onProvideFeedback}
/>
);
Expand Down
16 changes: 6 additions & 10 deletions src/components/structures/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
let errorText: ReactNode;
// Some error strings only apply for logging in
if (error.httpStatus === 400 && username && username.indexOf("@") > 0) {
errorText = _t("This homeserver does not support login using email address.");
errorText = _t("auth|unsupported_auth_email");
} else {
errorText = messageForLoginError(error, this.props.serverConfig);
}
Expand Down Expand Up @@ -273,7 +273,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
} catch (e) {
logger.error("Problem parsing URL or unhandled error doing .well-known discovery:", e);

let message = _t("Failed to perform homeserver discovery");
let message = _t("auth|failed_homeserver_discovery");
if (e instanceof UserFriendlyError && e.translatedMessage) {
message = e.translatedMessage;
}
Expand Down Expand Up @@ -398,9 +398,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>

if (supportedFlows.length === 0) {
this.setState({
errorText: _t(
"This homeserver doesn't offer any login flows that are supported by this client.",
),
errorText: _t("auth|unsupported_auth"),
});
}
},
Expand Down Expand Up @@ -532,20 +530,18 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
<div className="mx_AuthBody_paddedFooter">
<div className="mx_AuthBody_paddedFooter_title">
<InlineSpinner w={20} h={20} />
{this.props.isSyncing ? _t("Syncing…") : _t("Signing In…")}
{this.props.isSyncing ? _t("auth|syncing") : _t("auth|signing_in")}
</div>
{this.props.isSyncing && (
<div className="mx_AuthBody_paddedFooter_subtitle">
{_t("If you've joined lots of rooms, this might take a while")}
</div>
<div className="mx_AuthBody_paddedFooter_subtitle">{_t("auth|sync_footer_subtitle")}</div>
)}
</div>
);
} else if (SettingsStore.getValue(UIFeature.Registration)) {
footer = (
<span className="mx_AuthBody_changeFlow">
{_t(
"New? <a>Create account</a>",
"auth|create_account_prompt",
{},
{
a: (sub) => (
Expand Down
10 changes: 5 additions & 5 deletions src/components/structures/auth/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ export default class Registration extends React.Component<IProps, IState> {
} else {
this.setState({
serverErrorIsFatal: true, // fatal because user cannot continue on this server
errorText: _t("Registration has been disabled on this homeserver."),
errorText: _t("auth|registration_disabled"),
// add empty flows array to get rid of spinner
flows: [],
});
}
} else {
logger.log("Unable to query for supported registration methods.", e);
this.setState({
errorText: _t("Unable to query for supported registration methods."),
errorText: _t("auth|failed_query_registration_methods"),
// add empty flows array to get rid of spinner
flows: [],
});
Expand Down Expand Up @@ -326,12 +326,12 @@ export default class Registration extends React.Component<IProps, IState> {
const flows = (response as IAuthData).flows ?? [];
const msisdnAvailable = flows.some((flow) => flow.stages.includes(AuthType.Msisdn));
if (!msisdnAvailable) {
errorText = _t("This server does not support authentication with a phone number.");
errorText = _t("auth|unsupported_auth_msisdn");
}
} else if (response instanceof MatrixError && response.errcode === "M_USER_IN_USE") {
errorText = _t("Someone already has that username, please try another.");
errorText = _t("auth|username_in_use");
} else if (response instanceof MatrixError && response.errcode === "M_THREEPID_IN_USE") {
errorText = _t("That e-mail address or phone number is already in use.");
errorText = _t("auth|3pid_in_use");
}

this.setState({
Expand Down
20 changes: 8 additions & 12 deletions src/components/structures/auth/SoftLogout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
e.errcode === "M_FORBIDDEN" &&
(e.httpStatus === 401 || e.httpStatus === 403)
) {
errorText = _t("Incorrect password");
errorText = _t("auth|incorrect_password");
}

this.setState({
Expand All @@ -173,7 +173,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {

Lifecycle.hydrateSession(credentials).catch((e) => {
logger.error(e);
this.setState({ busy: false, errorText: _t("Failed to re-authenticate") });
this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") });
});
};

Expand Down Expand Up @@ -239,7 +239,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
{_t("action|sign_in")}
</AccessibleButton>
<AccessibleButton onClick={this.onForgotPassword} kind="link">
{_t("Forgotten your password?")}
{_t("auth|forgot_password_prompt")}
</AccessibleButton>
</form>
);
Expand Down Expand Up @@ -270,11 +270,11 @@ export default class SoftLogout extends React.Component<IProps, IState> {
}

if (this.state.loginView === LoginView.Password) {
return this.renderPasswordForm(_t("Enter your password to sign in and regain access to your account."));
return this.renderPasswordForm(_t("auth|soft_logout_intro_password"));
}

if (this.state.loginView === LoginView.SSO || this.state.loginView === LoginView.CAS) {
return this.renderSsoForm(_t("Sign in and regain access to your account."));
return this.renderSsoForm(_t("auth|soft_logout_intro_sso"));
}

if (this.state.loginView === LoginView.PasswordWithSocialSignOn) {
Expand All @@ -284,7 +284,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
// Note: "mx_AuthBody_centered" text taken from registration page.
return (
<>
<p>{_t("Sign in and regain access to your account.")}</p>
<p>{_t("auth|soft_logout_intro_sso")}</p>
{this.renderSsoForm(null)}
<h2 className="mx_AuthBody_centered">
{_t("auth|sso_or_username_password", {
Expand All @@ -298,19 +298,15 @@ 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.")}
</p>
);
return <p>{_t("auth|soft_logout_intro_unsupported_auth")}</p>;
}

public render(): React.ReactNode {
return (
<AuthPage>
<AuthHeader />
<AuthBody>
<h1>{_t("You're signed out")}</h1>
<h1>{_t("auth|soft_logout_heading")}</h1>

<h2>{_t("action|sign_in")}</h2>
<div>{this.renderSignInSection()}</div>
Expand Down
12 changes: 5 additions & 7 deletions src/components/structures/auth/forgot-password/CheckEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,18 @@ export const CheckEmail: React.FC<CheckEmailProps> = ({
<EMailPromptIcon className="mx_AuthBody_emailPromptIcon--shifted" />
<h1>{_t("Check your email to continue")}</h1>
<div className="mx_AuthBody_text">
<p>
{_t("Follow the instructions sent to <b>%(email)s</b>", { email: email }, { b: (t) => <b>{t}</b> })}
</p>
<p>{_t("auth|check_email_explainer", { email: email }, { b: (t) => <b>{t}</b> })}</p>
<div className="mx_AuthBody_did-not-receive">
<span className="mx_VerifyEMailDialog_text-light">{_t("Wrong email address?")}</span>
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_wrong_email_prompt")}</span>
<AccessibleButton className="mx_AuthBody_resend-button" kind="link" onClick={onReEnterEmailClick}>
{_t("Re-enter email address")}
{_t("auth|check_email_wrong_email_button")}
</AccessibleButton>
</div>
</div>
{errorText && <ErrorMessage message={errorText} />}
<input onClick={onSubmitForm} type="button" className="mx_Login_submit" value={_t("action|next")} />
<div className="mx_AuthBody_did-not-receive">
<span className="mx_VerifyEMailDialog_text-light">{_t("Did not receive it?")}</span>
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_resend_prompt")}</span>
<AccessibleButton
className="mx_AuthBody_resend-button"
kind="link"
Expand All @@ -79,7 +77,7 @@ export const CheckEmail: React.FC<CheckEmailProps> = ({
{_t("action|resend")}
<Tooltip
id={tooltipId}
label={_t("Verification link email resent!")}
label={_t("auth|check_email_resend_tooltip")}
alignment={Alignment.Top}
visible={tooltipVisible}
/>
Expand Down
14 changes: 5 additions & 9 deletions src/components/structures/auth/forgot-password/EnterEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,18 @@ export const EnterEmail: React.FC<EnterEmailProps> = ({
return (
<>
<EmailIcon className="mx_AuthBody_icon" />
<h1>{_t("Enter your email to reset password")}</h1>
<h1>{_t("auth|enter_email_heading")}</h1>
<p className="mx_AuthBody_text">
{_t(
"<b>%(homeserver)s</b> will send you a verification link to let you reset your password.",
{ homeserver },
{ b: (t) => <b>{t}</b> },
)}
{_t("auth|enter_email_explainer", { homeserver }, { b: (t) => <b>{t}</b> })}
</p>
<form onSubmit={onSubmit}>
<fieldset disabled={loading}>
<div className="mx_AuthBody_fieldRow">
<EmailField
name="reset_email" // define a name so browser's password autofill gets less confused
label="Email address"
labelRequired={_td("The email address linked to your account must be entered.")}
labelInvalid={_td("The email address doesn't appear to be valid.")}
labelRequired={_td("auth|forgot_password_email_required")}
labelInvalid={_td("auth|forgot_password_email_invalid")}
value={email}
autoFocus={true}
onChange={(event: React.FormEvent<HTMLInputElement>) => onInputChanged("email", event)}
Expand All @@ -99,7 +95,7 @@ export const EnterEmail: React.FC<EnterEmailProps> = ({
onLoginClick();
}}
>
{_t("Sign in instead")}
{_t("auth|sign_in_instead")}
</AccessibleButton>
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export const VerifyEmailModal: React.FC<Props> = ({
return (
<>
<EmailPromptIcon className="mx_AuthBody_emailPromptIcon" />
<h1>{_t("Verify your email to continue")}</h1>
<h1>{_t("auth|verify_email_heading")}</h1>
<p>
{_t(
"We need to know it’s you before resetting your password. Click the link in the email we just sent to <b>%(email)s</b>",
"auth|verify_email_explainer",
{
email,
},
Expand All @@ -65,7 +65,7 @@ export const VerifyEmailModal: React.FC<Props> = ({
</p>

<div className="mx_AuthBody_did-not-receive">
<span className="mx_VerifyEMailDialog_text-light">{_t("Did not receive it?")}</span>
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_resend_prompt")}</span>
<AccessibleButton
className="mx_AuthBody_resend-button"
kind="link"
Expand All @@ -76,7 +76,7 @@ export const VerifyEmailModal: React.FC<Props> = ({
{_t("action|resend")}
<Tooltip
id={tooltipId}
label={_t("Verification link email resent!")}
label={_t("auth|check_email_resend_tooltip")}
alignment={Alignment.Top}
visible={tooltipVisible}
/>
Expand All @@ -85,9 +85,9 @@ export const VerifyEmailModal: React.FC<Props> = ({
</div>

<div className="mx_AuthBody_did-not-receive">
<span className="mx_VerifyEMailDialog_text-light">{_t("Wrong email address?")}</span>
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_wrong_email_prompt")}</span>
<AccessibleButton className="mx_AuthBody_resend-button" kind="link" onClick={onReEnterEmailClick}>
{_t("Re-enter email address")}
{_t("auth|check_email_wrong_email_button")}
</AccessibleButton>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/components/views/beta/BetaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const BetaCard: React.FC<IProps> = ({ title: titleOverride, featureId }) => {
}}
kind="primary"
>
{_t("Feedback")}
{_t("common|feedback")}
</AccessibleButton>
);
}
Expand Down
Loading

0 comments on commit e9c9377

Please sign in to comment.