Skip to content

Commit 9694719

Browse files
authored
Login form spanish translation (#1535)
* NewFolderModal spanish translation translations.json (both languages EN - ES) changes in NewFileForm.jsx and NewFileModal.jsx to link the new keys. * Login Form translation * SocialAuthButton.jsx Changes Interpolation in translations.json
1 parent 3253770 commit 9694719

File tree

6 files changed

+91
-54
lines changed

6 files changed

+91
-54
lines changed

client/components/Nav.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,13 @@ class Nav extends React.PureComponent {
608608
<ul className="nav__items-right" title="user-menu">
609609
<li className="nav__item">
610610
<Link to="/login" className="nav__auth-button">
611-
<span className="nav__item-header">{this.props.t('Nav.Login.Login')}</span>
611+
<span className="nav__item-header">{this.props.t('Nav.Login')}</span>
612612
</Link>
613613
</li>
614-
<span className="nav__item-or">{this.props.t('Nav.Login.LoginOr')}</span>
614+
<span className="nav__item-or">{this.props.t('Nav.LoginOr')}</span>
615615
<li className="nav__item">
616616
<Link to="/signup" className="nav__auth-button">
617-
<span className="nav__item-header">{this.props.t('Nav.Login.SignUp')}</span>
617+
<span className="nav__item-header">{this.props.t('Nav.SignUp')}</span>
618618
</Link>
619619
</li>
620620
</ul>

client/modules/User/components/LoginForm.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
3+
import { withTranslation } from 'react-i18next';
4+
import i18n from 'i18next';
45
import Button from '../../../common/Button';
56

67
import { domOnlyProps } from '../../../utils/reduxFormUtils';
@@ -12,21 +13,21 @@ function LoginForm(props) {
1213
return (
1314
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
1415
<p className="form__field">
15-
<label htmlFor="email" className="form__label">Email or Username</label>
16+
<label htmlFor="email" className="form__label">{props.t('LoginForm.UsernameOrEmail')}</label>
1617
<input
1718
className="form__input"
18-
aria-label="email or username"
19+
aria-label={props.t('LoginForm.UsernameOrEmailARIA')}
1920
type="text"
2021
id="email"
2122
{...domOnlyProps(email)}
2223
/>
2324
{email.touched && email.error && <span className="form-error">{email.error}</span>}
2425
</p>
2526
<p className="form__field">
26-
<label htmlFor="password" className="form__label">Password</label>
27+
<label htmlFor="password" className="form__label">{props.t('LoginForm.Password')}</label>
2728
<input
2829
className="form__input"
29-
aria-label="password"
30+
aria-label={props.t('LoginForm.PasswordARIA')}
3031
type="password"
3132
id="password"
3233
{...domOnlyProps(password)}
@@ -36,7 +37,7 @@ function LoginForm(props) {
3637
<Button
3738
type="submit"
3839
disabled={submitting || pristine}
39-
>Log In
40+
>{props.t('LoginForm.Submit')}
4041
</Button>
4142
</form>
4243
);
@@ -52,7 +53,8 @@ LoginForm.propTypes = {
5253
submitting: PropTypes.bool,
5354
pristine: PropTypes.bool,
5455
invalid: PropTypes.bool,
55-
previousPath: PropTypes.string.isRequired
56+
previousPath: PropTypes.string.isRequired,
57+
t: PropTypes.func.isRequired
5658
};
5759

5860
LoginForm.defaultProps = {
@@ -61,4 +63,4 @@ LoginForm.defaultProps = {
6163
invalid: false
6264
};
6365

64-
export default LoginForm;
66+
export default withTranslation()(LoginForm);

client/modules/User/components/SocialAuthButton.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import styled from 'styled-components';
4+
import i18n from 'i18next';
5+
import { withTranslation } from 'react-i18next';
46

57
import { remSize } from '../../../theme';
68

@@ -12,11 +14,6 @@ const authUrls = {
1214
google: '/auth/google'
1315
};
1416

15-
const labels = {
16-
github: 'Login with GitHub',
17-
google: 'Login with Google'
18-
};
19-
2017
const icons = {
2118
github: GithubIcon,
2219
google: GoogleIcon
@@ -31,11 +28,15 @@ const StyledButton = styled(Button)`
3128
width: ${remSize(300)};
3229
`;
3330

34-
function SocialAuthButton({ service }) {
31+
function SocialAuthButton({ service, t }) {
3532
const ServiceIcon = icons[service];
33+
const labels = {
34+
github: t('SocialAuthButton.Github'),
35+
google: t('SocialAuthButton.Google')
36+
};
3637
return (
3738
<StyledButton
38-
iconBefore={<ServiceIcon aria-label={`${service} logo`} />}
39+
iconBefore={<ServiceIcon aria-label={t('SocialAuthButton.LogoARIA', { serviceauth: service })} />}
3940
href={authUrls[service]}
4041
>
4142
{labels[service]}
@@ -46,7 +47,10 @@ function SocialAuthButton({ service }) {
4647
SocialAuthButton.services = services;
4748

4849
SocialAuthButton.propTypes = {
49-
service: PropTypes.oneOf(['github', 'google']).isRequired
50+
service: PropTypes.oneOf(['github', 'google']).isRequired,
51+
t: PropTypes.func.isRequired
5052
};
5153

52-
export default SocialAuthButton;
54+
const SocialAuthButtonPublic = withTranslation()(SocialAuthButton);
55+
SocialAuthButtonPublic.services = services;
56+
export default SocialAuthButtonPublic;

client/modules/User/pages/LoginView.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React from 'react';
33
import { reduxForm } from 'redux-form';
44
import { Link, browserHistory } from 'react-router';
55
import { Helmet } from 'react-helmet';
6+
import { withTranslation } from 'react-i18next';
7+
import i18n from 'i18next';
68
import { validateAndLoginUser } from '../actions';
79
import LoginForm from '../components/LoginForm';
810
import { validateLogin } from '../../../utils/reduxFormUtils';
@@ -34,23 +36,23 @@ class LoginView extends React.Component {
3436
<Nav layout="dashboard" />
3537
<main className="form-container">
3638
<Helmet>
37-
<title>p5.js Web Editor | Login</title>
39+
<title>{this.props.t('LoginView.Title')}</title>
3840
</Helmet>
3941
<div className="form-container__content">
40-
<h2 className="form-container__title">Log In</h2>
42+
<h2 className="form-container__title">{this.props.t('LoginView.Login')}</h2>
4143
<LoginForm {...this.props} />
42-
<h2 className="form-container__divider">Or</h2>
44+
<h2 className="form-container__divider">{this.props.t('LoginView.LoginOr')}</h2>
4345
<div className="form-container__stack">
4446
<SocialAuthButton service={SocialAuthButton.services.github} />
4547
<SocialAuthButton service={SocialAuthButton.services.google} />
4648
</div>
4749
<p className="form__navigation-options">
48-
Don&apos;t have an account?&nbsp;
49-
<Link className="form__signup-button" to="/signup">Sign Up</Link>
50+
{this.props.t('LoginView.DontHaveAccount')}
51+
<Link className="form__signup-button" to="/signup">{this.props.t('LoginView.SignUp')}</Link>
5052
</p>
5153
<p className="form__navigation-options">
52-
Forgot your password?&nbsp;
53-
<Link className="form__reset-password-button" to="/reset-password">Reset your password</Link>
54+
{this.props.t('LoginView.ForgotPassword')}
55+
<Link className="form__reset-password-button" to="/reset-password"> {this.props.t('LoginView.ResetPassword')}</Link>
5456
</p>
5557
</div>
5658
</main>
@@ -76,7 +78,8 @@ LoginView.propTypes = {
7678
previousPath: PropTypes.string.isRequired,
7779
user: PropTypes.shape({
7880
authenticated: PropTypes.bool
79-
})
81+
}),
82+
t: PropTypes.func.isRequired
8083
};
8184

8285
LoginView.defaultProps = {
@@ -85,8 +88,8 @@ LoginView.defaultProps = {
8588
}
8689
};
8790

88-
export default reduxForm({
91+
export default withTranslation()(reduxForm({
8992
form: 'login',
9093
fields: ['email', 'password'],
9194
validate: validateLogin
92-
}, mapStateToProps, mapDispatchToProps)(LoginView);
95+
}, mapStateToProps, mapDispatchToProps)(LoginView));

translations/locales/en-US/translations.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@
3333
"Lang": "Language",
3434
"BackEditor": "Back to Editor",
3535
"WarningUnsavedChanges": "Are you sure you want to leave this page? You have unsaved changes.",
36-
"Login": {
37-
"Login": "Log in",
38-
"LoginOr": "or",
39-
"SignUp": "Sign up",
40-
"Email": "email",
41-
"Username": "username",
42-
"LoginGithub": "Login with Github",
43-
"LoginGoogle": "Login with Google",
44-
"DontHaveAccount": "Don't have an account?",
45-
"ForgotPassword": "Forgot your password?",
46-
"ResetPassword": "Reset your password"
47-
},
36+
"Login": "Log in",
37+
"LoginOr": "or",
38+
"SignUp": "Sign up",
4839
"Auth": {
4940
"Welcome": "Welcome",
5041
"Hello": "Hello",
@@ -57,6 +48,29 @@
5748
"LogOut": "Log Out"
5849
}
5950
},
51+
"LoginForm": {
52+
"UsernameOrEmail": "Email or Username",
53+
"UsernameOrEmailARIA": "Email or Username",
54+
"Password": "Password",
55+
"PasswordARIA": "Password",
56+
"Submit": "Log In"
57+
},
58+
"LoginView": {
59+
"Title": "p5.js Web Editor | Login",
60+
"Login": "Log In",
61+
"LoginOr": "or",
62+
"SignUp": "Sign Up",
63+
"Email": "email",
64+
"Username": "username",
65+
"DontHaveAccount": "Don't have an account? ",
66+
"ForgotPassword": "Forgot your password? ",
67+
"ResetPassword": "Reset your password"
68+
},
69+
"SocialAuthButton": {
70+
"Github": "Login with Github",
71+
"LogoARIA": "{{serviceauth}} logo",
72+
"Google": "Login with Google"
73+
},
6074
"About": {
6175
"Title": "About",
6276
"TitleHelmet": "p5.js Web Editor | About",

translations/locales/es-419/translations.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@
3333
"Lang": "Lenguaje",
3434
"BackEditor": "Regresa al editor",
3535
"WarningUnsavedChanges": "¿Realmente quieres salir de la página? Tienes cambios sin guardar.",
36-
"Login": {
37-
"Login": "Ingresa",
38-
"LoginOr": "o",
39-
"SignUp": "registráte",
40-
"Email": "correo electrónico",
41-
"Username": "Identificación",
42-
"LoginGithub": "Ingresa con Github",
43-
"LoginGoogle": "Ingresa con Google",
44-
"DontHaveAccount": "¿No tienes cuenta?",
45-
"ForgotPassword": "¿Olvidaste tu contraseña?",
46-
"ResetPassword": "Regenera tu contraseña"
47-
},
36+
"Login": "Ingresa",
37+
"LoginOr": "o",
38+
"SignUp": "Registráte",
4839
"Auth": {
4940
"Welcome": "Hola",
5041
"Hello": "Hola",
@@ -57,6 +48,29 @@
5748
"LogOut": "Cerrar sesión"
5849
}
5950
},
51+
"LoginForm": {
52+
"UsernameOrEmail": "Correo o Identificación",
53+
"UsernameOrEmailARIA": "Introduce Correo o Identificación",
54+
"Password": "Contraseña",
55+
"PasswordARIA": "Contraseña",
56+
"Submit": "Ingresa"
57+
},
58+
"LoginView": {
59+
"Title": " Editor Web p5.js | Ingreso",
60+
"Login": "Ingresa",
61+
"LoginOr": "o",
62+
"SignUp": "Registráte",
63+
"Email": "correo electrónico",
64+
"Username": "Identificación",
65+
"DontHaveAccount": "¿No tienes cuenta? ",
66+
"ForgotPassword": "¿Olvidaste tu contraseña? ",
67+
"ResetPassword": "Regenera tu contraseña"
68+
},
69+
"SocialAuthButton": {
70+
"Github": "Ingresa con Github",
71+
"LogoARIA": "Logo de {{serviceauth}}",
72+
"Google": "Ingresa con Google"
73+
},
6074
"About": {
6175
"Title": "Acerca de",
6276
"TitleHelmet": "Editor Web p5.js | Acerca de",

0 commit comments

Comments
 (0)