Skip to content

Commit

Permalink
Merge pull request #9177 from neinteractiveliterature/remove-inline-t…
Browse files Browse the repository at this point in the history
…ranslation-defaults

Remove inline translation defaults; don't show items with empty-string public descriptions
  • Loading branch information
nbudin authored Jul 10, 2024
2 parents a7862a0 + ab3c8fd commit e5e51fb
Show file tree
Hide file tree
Showing 154 changed files with 1,043 additions and 2,684 deletions.
23 changes: 8 additions & 15 deletions app/javascript/Authentication/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,30 @@ export default LoadQueryWrapper(useEditUserQuery, function EditUserForm({ data:

return (
<>
<h1 className="mb-4">{t('authentication.editUser.header', 'Update your account')}</h1>

<h1 className="mb-4">{t('authentication.editUser.header')}</h1>
<AccountFormContent />

<form onSubmit={onSubmit} className="card">
<div className="card-header">{t('authentication.editUser.accountDataHeader', 'Account data')}</div>
<div className="card-header">{t('authentication.editUser.accountDataHeader')}</div>

<div className="card-body">
<UserFormFields formState={formState} setFormState={setFormState} showNameWarning />
<div className="mb-3">
<label className="form-label" htmlFor={passwordFieldId}>
{t('authentication.editUser.passwordLabel', 'Password')}
{t('authentication.editUser.passwordLabel')}
</label>
<Suspense fallback={<LoadingIndicator iconSet="bootstrap-icons" />}>
<PasswordInputWithStrengthCheck id={passwordFieldId} value={password} onChange={setPassword} />
</Suspense>
<small className="form-text text-muted">
{t('authentication.editUser.passwordHelpText', 'Leave blank if you don’t want to change it')}
</small>
<small className="form-text text-muted">{t('authentication.editUser.passwordHelpText')}</small>
</div>
<PasswordConfirmationInput
password={password}
value={passwordConfirmation}
onChange={setPasswordConfirmation}
/>
<BootstrapFormInput
label={t('authentication.editUser.currentPasswordLabel', 'Current password')}
helpText={t(
'authentication.editUser.currentPasswordHelpText',
'We need your current password to verify your identity',
)}
label={t('authentication.editUser.currentPasswordLabel')}
helpText={t('authentication.editUser.currentPasswordHelpText')}
type="password"
value={currentPassword}
onTextChange={setCurrentPassword}
Expand All @@ -137,8 +130,8 @@ export default LoadQueryWrapper(useEditUserQuery, function EditUserForm({ data:
type="submit"
className="btn btn-primary"
disabled={updateUserInProgress}
value={t('authentication.editUser.updateAccountButton', 'Update account').toString()}
aria-label={t('authentication.editUser.updateAccountButton', 'Update account')}
value={t('authentication.editUser.updateAccountButton').toString()}
aria-label={t('authentication.editUser.updateAccountButton')}
/>
</div>
</div>
Expand Down
16 changes: 7 additions & 9 deletions app/javascript/Authentication/ForgotPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ function ForgotPasswordForm(): JSX.Element {
<>
<form onSubmit={onSubmit}>
<div className="modal-header bg-light align-items-center">
<div className="lead flex-grow-1">
{t('authentication.forgotPasswordForm.header', 'Forgot your password?')}
</div>
<div className="lead flex-grow-1">{t('authentication.forgotPasswordForm.header')}</div>
</div>

<div className="modal-body">
Expand All @@ -81,7 +79,7 @@ function ForgotPasswordForm(): JSX.Element {
) : (
<BootstrapFormInput
type="email"
label={t('authentication.forgotPasswordForm.emailLabel', 'Email')}
label={t('authentication.forgotPasswordForm.emailLabel')}
value={email}
onTextChange={setEmail}
disabled={resetPasswordInProgress}
Expand All @@ -100,7 +98,7 @@ function ForgotPasswordForm(): JSX.Element {
setCurrentView('signUp');
}}
>
{t('authentication.signUpLink', 'Sign up for an account')}
{t('authentication.signUpLink')}
</button>
<button
type="button"
Expand All @@ -109,7 +107,7 @@ function ForgotPasswordForm(): JSX.Element {
setCurrentView('signIn');
}}
>
{t('authentication.logInLink', 'Log in to an existing account')}
{t('authentication.logInLink')}
</button>
</div>
<div>
Expand All @@ -119,15 +117,15 @@ function ForgotPasswordForm(): JSX.Element {
disabled={resetPasswordInProgress}
onClick={closeModal}
>
{success ? t('buttons.ok', 'OK') : t('buttons.cancel', 'Cancel')}
{success ? t('buttons.ok') : t('buttons.cancel')}
</button>
{!success && (
<input
type="submit"
className="btn btn-primary"
disabled={resetPasswordInProgress}
value={t('authentication.forgotPassword.sendInstructionsButton', 'Send instructions').toString()}
aria-label={t('authentication.forgotPassword.sendInstructionsButton', 'Send instructions')}
value={t('authentication.forgotPassword.sendInstructionsButton').toString()}
aria-label={t('authentication.forgotPassword.sendInstructionsButton')}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function PasswordConfirmationInput({ value, onChange, password }: PasswordConfir
return (
<BootstrapFormInput
type="password"
label={t('authentication.confirmPasswordLabel', 'Confirm password')}
label={t('authentication.confirmPasswordLabel')}
className={classNames('form-control', { 'is-invalid': confirmationInvalid })}
value={value}
onTextChange={onChange}
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/Authentication/PasswordInputWithStrengthCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ function PasswordInputWithStrengthCheck({ id, value, onChange }: PasswordInputWi
'text-success': score >= 4,
};
const scoreTextTranslated = {
insecure: t('authentication.passwordInput.insecure', 'insecure'),
fair: t('authentication.passwordInput.fair', 'fair'),
good: t('authentication.passwordInput.good', 'good'),
great: t('authentication.passwordInput.great', 'great'),
insecure: t('authentication.passwordInput.insecure'),
fair: t('authentication.passwordInput.fair'),
good: t('authentication.passwordInput.good'),
great: t('authentication.passwordInput.great'),
}[scoreText];

const [dropdownButton, setDropdownButton] = useState<HTMLButtonElement | null>(null);
Expand All @@ -115,7 +115,7 @@ function PasswordInputWithStrengthCheck({ id, value, onChange }: PasswordInputWi
type="password"
value={value}
onChange={(event) => onChange(event.target.value)}
aria-label={t('authentication.passwordInput.label', 'Password')}
aria-label={t('authentication.passwordInput.label')}
/>
<div style={{ right: 0, top: 0, position: 'absolute' }} className={classNames('me-2', 'mt-2')}>
<button
Expand All @@ -141,7 +141,7 @@ function PasswordInputWithStrengthCheck({ id, value, onChange }: PasswordInputWi
<>
{' '}
<i className="bi-question-circle-fill" style={{ cursor: 'pointer' }}>
<span className="visually-hidden">{t('buttons.help', 'Help')}</span>
<span className="visually-hidden">{t('buttons.help')}</span>
</i>
</>
)}
Expand Down Expand Up @@ -178,7 +178,7 @@ function PasswordInputWithStrengthCheck({ id, value, onChange }: PasswordInputWi
className={classNames('progress-bar', scoreProgressClasses)}
aria-valuemin={0}
aria-valuemax={4}
aria-label={t('authentication.passwordInput.strengthMeterLabel', 'Password strength')}
aria-label={t('authentication.passwordInput.strengthMeterLabel')}
/>
</div>
</div>
Expand Down
9 changes: 4 additions & 5 deletions app/javascript/Authentication/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ function ResetPassword(): JSX.Element {

return (
<>
<h1 className="mb-4">{t('authentication.resetPassword.header', 'Reset password')}</h1>

<h1 className="mb-4">{t('authentication.resetPassword.header')}</h1>
<form onSubmit={onSubmit}>
<div className="card">
<div className="card-body">
<div className="mb-3">
<label className="form-label" htmlFor={passwordId}>
{t('authentication.resetPassword.passwordLabel', 'Password')}
{t('authentication.resetPassword.passwordLabel')}
</label>
<Suspense fallback={<LoadingIndicator iconSet="bootstrap-icons" />}>
<PasswordInputWithStrengthCheck value={password} onChange={setPassword} id={passwordId} />
Expand All @@ -89,9 +88,9 @@ function ResetPassword(): JSX.Element {
<div className="card-footer text-end">
<input
type="submit"
value={t('authentication.resetPassword.setPasswordButton', 'Set password').toString()}
value={t('authentication.resetPassword.setPasswordButton').toString()}
className="btn btn-primary"
aria-label={t('authentication.resetPassword.setPasswordButton', 'Set password')}
aria-label={t('authentication.resetPassword.setPasswordButton')}
/>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions app/javascript/Authentication/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,29 @@ function SignInForm(): JSX.Element {
<>
<form onSubmit={submit}>
<div className="modal-header bg-light align-items-center">
<div className="lead flex-grow-1">{t('authentication.signInForm.header', 'Log in')}</div>
<div className="lead flex-grow-1">{t('authentication.signInForm.header')}</div>
</div>

<div className="modal-body">
<BootstrapFormInput
type="email"
label={t('authentication.signInForm.emailLabel', 'Email')}
label={t('authentication.signInForm.emailLabel')}
value={email}
onTextChange={setEmail}
disabled={submitInProgress}
/>

<BootstrapFormInput
type="password"
label={t('authentication.signInForm.passwordLabel', 'Password')}
label={t('authentication.signInForm.passwordLabel')}
value={password}
onTextChange={setPassword}
disabled={submitInProgress}
/>

<BootstrapFormCheckbox
type="checkbox"
label={t('authentication.signInForm.rememberMeLabel', 'Remember me')}
label={t('authentication.signInForm.rememberMeLabel')}
checked={rememberMe}
onCheckedChange={setRememberMe}
disabled={submitInProgress}
Expand All @@ -142,7 +142,7 @@ function SignInForm(): JSX.Element {
setCurrentView('signUp');
}}
>
{t('authentication.signUpLink', 'Sign up for an account')}
{t('authentication.signUpLink')}
</button>
<button
type="button"
Expand All @@ -151,19 +151,19 @@ function SignInForm(): JSX.Element {
setCurrentView('forgotPassword');
}}
>
{t('authentication.forgotPasswordLink', 'Forgot your password?')}
{t('authentication.forgotPasswordLink')}
</button>
</div>
<div>
<button type="button" className="btn btn-secondary me-2" disabled={submitInProgress} onClick={onCancel}>
{t('buttons.cancel', 'Cancel')}
{t('buttons.cancel')}
</button>
<input
type="submit"
className="btn btn-primary"
disabled={submitInProgress}
value={t('authentication.signInForm.logInButton', 'Log in').toString()}
aria-label={t('authentication.signInForm.logInButton', 'Log in')}
value={t('authentication.signInForm.logInButton').toString()}
aria-label={t('authentication.signInForm.logInButton')}
/>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/Authentication/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ function SignUpForm(): JSX.Element {
<>
<form onSubmit={submit}>
<div className="modal-header bg-light align-items-center">
<div className="lead flex-grow-1">{t('authentication.signUpForm.header', 'Sign up')}</div>
<div className="lead flex-grow-1">{t('authentication.signUpForm.header')}</div>
</div>

<div className="modal-body">
<AccountFormContent />
<UserFormFields formState={formState} setFormState={setFormState} />
<div className="mb-3">
<label className="form-label" htmlFor={passwordFieldId}>
{t('authentication.signUpForm.passwordLabel', 'Password')}
{t('authentication.signUpForm.passwordLabel')}
</label>
<Suspense fallback={<LoadingIndicator iconSet="bootstrap-icons" />}>
<PasswordInputWithStrengthCheck id={passwordFieldId} value={password} onChange={setPassword} />
Expand All @@ -126,7 +126,7 @@ function SignUpForm(): JSX.Element {
setCurrentView('signIn');
}}
>
{t('authentication.logInLink', 'Log in to an existing account')}
{t('authentication.logInLink')}
</button>
<button
type="button"
Expand All @@ -135,19 +135,19 @@ function SignUpForm(): JSX.Element {
setCurrentView('forgotPassword');
}}
>
{t('authentication.forgotPasswordLink', 'Forgot your password?')}
{t('authentication.forgotPasswordLink')}
</button>
</div>
<div>
<button type="button" className="btn btn-secondary me-2" disabled={submitInProgress} onClick={closeModal}>
{t('buttons.cancel', 'Cancel')}
{t('buttons.cancel')}
</button>
<input
type="submit"
className="btn btn-primary"
disabled={submitInProgress}
value={t('authentication.signUpForm.signUpButton', 'Sign up').toString()}
aria-label={t('authentication.signUpForm.signUpButton', 'Sign up')}
value={t('authentication.signUpForm.signUpButton').toString()}
aria-label={t('authentication.signUpForm.signUpButton')}
/>
</div>
</div>
Expand Down
13 changes: 4 additions & 9 deletions app/javascript/Authentication/UserFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ function UserFormFields({ formState, setFormState, showNameWarning }: UserFormFi
<>
<fieldset>
<BootstrapFormInput
label={t('authentication.userForm.firstNameLabel', 'First name')}
label={t('authentication.userForm.firstNameLabel')}
value={formState.first_name ?? ''}
onTextChange={setFirstName}
/>
<BootstrapFormInput
label={t('authentication.userForm.lastNameLabel', 'Last name')}
label={t('authentication.userForm.lastNameLabel')}
value={formState.last_name ?? ''}
onTextChange={setLastName}
/>
Expand All @@ -37,17 +37,12 @@ function UserFormFields({ formState, setFormState, showNameWarning }: UserFormFi
<h1 className="me-4">
<i className="bi-exclamation-triangle-fill" />
</h1>
<div className="flex-grow-1">
{t(
'authentication.userForm.nameWarning',
'Please note that each convention keeps a separate record of your name. Changing your name here will apply to new conventions you sign up for in the future. To change your name on existing conventions, please go to each convention’s web site and choose “my profile” from the menu.',
)}
</div>
<div className="flex-grow-1">{t('authentication.userForm.nameWarning')}</div>
</div>
</div>
)}
<BootstrapFormInput
label={t('authentication.userForm.emailLabel', 'Email')}
label={t('authentication.userForm.emailLabel')}
type="email"
value={formState.email ?? ''}
onTextChange={setEmail}
Expand Down
6 changes: 1 addition & 5 deletions app/javascript/Authentication/useAuthorizationRequired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import useLoginRequired from './useLoginRequired';
export function AuthorizationError() {
const { t } = useTranslation();

return (
<div className="alert alert-danger">
{t('errors.unauthorized', 'Sorry, your account is not authorized to view this page.')}
</div>
);
return <div className="alert alert-danger">{t('errors.unauthorized')}</div>;
}

type AbilityType = AppRootContextValue['currentAbility'];
Expand Down
Loading

0 comments on commit e5e51fb

Please sign in to comment.