Email translations

This commit is contained in:
vjrj 2018-01-22 13:27:46 +01:00
parent 952431d296
commit 6c8fa91f64
30 changed files with 1844 additions and 107 deletions

View file

@ -11,7 +11,7 @@ const Privacy = props => (
<div className="Privacy">
<Page
title={props.t('Política de Privacidad')}
subtitle={props.t('Última actualización, {{when}}', { when: dateParseShortFormat('2017-01-19') })}
subtitle={props.t('Última actualización, {{when}}', { when: dateParseShortFormat('2018-01-19') })}
page="privacy"
/>
</div>

View file

@ -48,34 +48,34 @@ class Profile extends React.Component {
required() {
// Only required if newPassword field has a value.
return component.newPassword.value.length > 0;
},
}
},
newPassword: {
required() {
// Only required if currentPassword field has a value.
return component.currentPassword.value.length > 0;
},
},
}
}
},
messages: {
firstName: {
required: this.t("¿Cuál es tu nombre?"),
required: this.t('¿Cuál es tu nombre?')
},
lastName: {
required: this.t("¿Cuál es tu apellido?"),
required: this.t('¿Cuál es tu apellido?')
},
emailAddress: {
required: this.t("Necesitamos una contraseña aquí."),
email: this.t("¿Es correcto este correo?"),
required: this.t('Necesitamos una contraseña aquí.'),
email: this.t('¿Es correcto este correo?')
},
currentPassword: {
required: this.t("Necesito tu contraseña si la quieres cambiar."),
required: this.t('Necesito tu contraseña si la quieres cambiar.')
},
newPassword: {
required: this.t("Necesito tu nueva contraseña si la quieres cambiar."),
},
required: this.t('Necesito tu nueva contraseña si la quieres cambiar.')
}
},
submitHandler() { component.handleSubmit(); },
submitHandler() { component.handleSubmit(); }
});
}
@ -104,16 +104,16 @@ class Profile extends React.Component {
profile: {
name: {
first: this.firstName.value,
last: this.lastName.value,
},
},
last: this.lastName.value
}
}
};
Meteor.call('users.editProfile', profile, (error) => {
if (error) {
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
} else {
Bert.alert(this.t("¡Perfíl actualizado!"), 'success');
Bert.alert(this.t('¡Perfíl actualizado!'), 'success');
}
});
@ -134,29 +134,32 @@ class Profile extends React.Component {
{Object.keys(user.services).map(service => (
<div key={service} className={`LoggedInWith ${service}`}>
<img src={`/${service}.svg`} alt={service} />
<p>{`You're logged in with ${_.capitalize(service)} using the email address ${user.services[service].email}.`}</p>
<p>{this.props.t('Has iniciado sesión con {{service}} usando la dirección de correo {{email}}.', { service: _.capitalize(service), email: user.services[service].email })}</p>
<Button
className={`btn btn-${service}`}
href={{
facebook: 'https://www.facebook.com/settings',
google: 'https://myaccount.google.com/privacy#personalinfo',
github: 'https://github.com/settings/profile',
github: 'https://github.com/settings/profile'
}[service]}
target="_blank"
>{this.t("Editar perfíl en")} {_.capitalize(service)}</Button>
>{this.t('Editar perfíl en')} {_.capitalize(service)}
</Button>
</div>
))}
</div>) : <div />;
}
renderPasswordUser(loading, user) {
const {t, i18n} = this.props;
const langName = { 'en': 'English', 'es': 'Español', 'gl': 'Galego', 'ast': 'Asturianu', 'ca': 'Català' };
const { t, i18n } = this.props;
const langName = {
en: 'English', es: 'Español', gl: 'Galego', ast: 'Asturianu', ca: 'Català'
};
return !loading ? (<div>
<Row>
<Col xs={6}>
<FormGroup>
<ControlLabel>{this.t("Nombre")}</ControlLabel>
<ControlLabel>{this.t('Nombre')}</ControlLabel>
<input
type="text"
name="firstName"
@ -168,7 +171,7 @@ class Profile extends React.Component {
</Col>
<Col xs={6}>
<FormGroup>
<ControlLabel>{this.t("Apellidos")}</ControlLabel>
<ControlLabel>{this.t('Apellidos')}</ControlLabel>
<input
type="text"
name="lastName"
@ -180,7 +183,7 @@ class Profile extends React.Component {
</Col>
</Row>
<FormGroup>
<ControlLabel>{this.t("Correo electrónico")}</ControlLabel>
<ControlLabel>{this.t('Correo electrónico')}</ControlLabel>
<input
type="email"
name="emailAddress"
@ -190,27 +193,28 @@ class Profile extends React.Component {
/>
</FormGroup>
<FormGroup>
<ControlLabel>{this.t("Idioma")}</ControlLabel>
<div className="btn-group">
<button className="btn btn-secondary btn-sm dropdown-toggle lang-selector" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{langName[i18n.language]}
</button>
<div className="dropdown-menu">
{i18n.languages.map(lang => (
<button
className="dropdown-item"
onClick={() => this.onLangSelect(lang)}
key={lang}
type="button">
{langName[lang]}
</button>
<ControlLabel>{this.t('Idioma')}</ControlLabel>
<div className="btn-group">
<button className="btn btn-secondary btn-sm dropdown-toggle lang-selector" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{langName[i18n.language]}
</button>
<div className="dropdown-menu">
{i18n.languages.map(lang => (
<button
className="dropdown-item"
onClick={() => this.onLangSelect(lang)}
key={lang}
type="button"
>
{langName[lang]}
</button>
))
}
</div>
</div>
</div>
</FormGroup>
<FormGroup>
<ControlLabel>{this.t("Contraseña actual")}</ControlLabel>
<ControlLabel>{this.t('Contraseña actual')}</ControlLabel>
<input
type="password"
name="currentPassword"
@ -219,23 +223,23 @@ class Profile extends React.Component {
/>
</FormGroup>
<FormGroup>
<ControlLabel>{this.t("Nueva contraseña")}</ControlLabel>
<ControlLabel>{this.t('Nueva contraseña')}</ControlLabel>
<input
type="password"
name="newPassword"
ref={newPassword => (this.newPassword = newPassword)}
className="form-control"
/>
<InputHint>{this.t("Usa al menos seis caracteres.")}</InputHint>
<InputHint>{this.t('Usa al menos seis caracteres.')}</InputHint>
</FormGroup>
<Button type="submit" bsStyle="success">{this.t("Guardar perfíl")}</Button>
<Button type="submit" bsStyle="success">{this.t('Guardar perfíl')}</Button>
</div>) : <div />;
}
renderProfileForm(loading, user) {
return !loading ? ({
password: this.renderPasswordUser,
oauth: this.renderOAuthUser,
oauth: this.renderOAuthUser
}[this.getUserType(user)])(loading, user) : <div />;
}
@ -244,7 +248,7 @@ class Profile extends React.Component {
return (<div className="Profile">
<Row className="align-items-center justify-content-center">
<Col xs={12} sm={6} md={4}>
<h4 className="page-header">{this.t("Editar perfíl")}</h4>
<h4 className="page-header">{this.t('Editar perfíl')}</h4>
<form ref={form => (this.form = form)} onSubmit={event => event.preventDefault()}>
{this.renderProfileForm(loading, user)}
</form>

View file

@ -1,7 +1,7 @@
/* eslint-disable react/jsx-indent-props */
import React from 'react';
import { Row, FormGroup, ControlLabel, Button } from 'react-bootstrap';
import { Row, FormGroup, ControlLabel, Button, Checkbox } from 'react-bootstrap';
import Col from '../../components/Col/Col';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
@ -15,7 +15,7 @@ import InputHint from '../../components/InputHint/InputHint';
import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter';
import validate from '../../../modules/validate';
import './Signup.scss';
import { translate } from 'react-i18next';
import { translate, Trans } from 'react-i18next';
import { T9n } from 'meteor-accounts-t9n';
class Signup extends React.Component {
@ -24,7 +24,8 @@ class Signup extends React.Component {
this.t = props.t;
this.handleSubmit = this.handleSubmit.bind(this);
// console.log(props.location.state);
this.state = props.location.state;
this.state = props.location.state ? props.location.state : {};
this.state.termsAccept = false;
}
componentDidMount() {
@ -68,12 +69,13 @@ class Signup extends React.Component {
}
handleSubmit() {
const { history, t } = this.props;
const { history, t, i18n } = this.props;
Accounts.createUser({
email: this.emailAddress.value,
password: this.password.value,
profile: {
lang: i18n.language,
name: {
first: this.firstName.value,
last: this.lastName.value
@ -90,6 +92,10 @@ class Signup extends React.Component {
});
}
setTermsAccept(termsAccept) {
this.setState({ termsAccept });
}
render() {
const { t, history } = this.props;
return (<div className="Signup">
@ -161,7 +167,11 @@ class Signup extends React.Component {
/>
<InputHint>{t('Usa al menos seis caracteres.')}</InputHint>
</FormGroup>
<Button type="submit" bsStyle="success">{t('Registrarse')}</Button>
<Checkbox inline={false} defaultChecked={this.state.termsAccept} onClick={e => this.setTermsAccept(e.target.checked)}>
<Trans className="mark-checkbox" parent="span" i18nKey="termsAccept">Acepto las <a target="_blank" href="/terms">condiciones de servicio</a> de este sitio</Trans>
</Checkbox>
<Button type="submit" disabled={!this.state.termsAccept} bsStyle="success">{t('Registrarse')}</Button>
<AccountPageFooter>
<p>{t('¿Ya tienes un cuenta?')} <Link to={{ pathname: '/login', state: this.state }} >{t('Iniciar sesión')}</Link>.</p>
</AccountPageFooter>

View file

@ -11,7 +11,7 @@ const Terms = props => (
<div className="Terms">
<Page
title={props.t('Términos de Servicio')}
subtitle={props.t('Última actualización, {{when}}', { when: dateParseShortFormat('2017-01-19') })}
subtitle={props.t('Última actualización, {{when}}', { when: dateParseShortFormat('2018-01-19') })}
page="terms"
/>
</div>