More i18n work
This commit is contained in:
parent
fffeb2a17a
commit
e9029cd8b9
13 changed files with 49 additions and 28 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ settings-demo.json
|
|||
settings-staging.json
|
||||
settings-production.json
|
||||
settings-development.json
|
||||
imports/ui/stylesheets/.sass-cache/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ import i18n from 'i18next';
|
|||
import backend from 'i18next-xhr-backend';
|
||||
import LngDetector from 'i18next-browser-languagedetector';
|
||||
import Cache from 'i18next-localstorage-cache';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
import en from 'meteor-accounts-t9n/build/en';
|
||||
import es from 'meteor-accounts-t9n/build/es';
|
||||
|
||||
// Adapted from: https://github.com/appigram/ryfma-boilerplate/blob/44c1eabfb9928b5623afab36a23997969e5beb02/imports/startup/client/i18n.js
|
||||
|
||||
|
|
@ -41,6 +44,8 @@ var backOpts = {
|
|||
jsonIndent: 2
|
||||
};
|
||||
|
||||
T9N_LANGUAGES='es,en';
|
||||
|
||||
i18n.use(backend)
|
||||
.use(LngDetector)
|
||||
.use(Cache)
|
||||
|
|
@ -79,8 +84,11 @@ i18n.use(backend)
|
|||
}
|
||||
}, function(err, t) {
|
||||
// initialized and ready to
|
||||
// console.log(t('AppName'));
|
||||
document.title = t("AppName");
|
||||
// https://github.com/softwarerero/meteor-accounts-t9n
|
||||
console.log("Language: " + i18n.language);
|
||||
T9n.setLanguage(i18n.language);
|
||||
console.log(T9n.get('error.accounts.User not found'));
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Meteor } from 'meteor/meteor';
|
|||
import { Bert } from 'meteor/themeteorchef:bert';
|
||||
import Icon from '../Icon/Icon';
|
||||
import { translate, Trans } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
import './OAuthLoginButton.scss';
|
||||
|
||||
|
|
@ -49,7 +50,8 @@ const OAuthLoginButton = ({ service, callback }) => (
|
|||
|
||||
OAuthLoginButton.defaultProps = {
|
||||
callback: (error) => {
|
||||
if (error) Bert.alert(error.message, 'danger');
|
||||
if (error) Bert.alert(T9n.get(`error.accounts.${error.message}`), 'danger');
|
||||
// Bert.alert(error.message, 'danger');
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { Grid, Alert, Button } from 'react-bootstrap';
|
||||
import { t, Trans, translate, Interpolate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
const handleResendVerificationEmail = (emailAddress, t) => {
|
||||
Meteor.call('users.sendVerificationEmail', (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Bert.alert(t("checkVerificationEmail", {email: emailAddress}), 'success');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButt
|
|||
import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter';
|
||||
import validate from '../../../modules/validate';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
class Login extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -48,7 +49,7 @@ class Login extends React.Component {
|
|||
|
||||
Meteor.loginWithPassword(this.emailAddress.value, this.password.value, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Bert.alert(this.t('Bienvenid@ de nuevo'), 'success');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { createContainer } from 'meteor/react-meteor-data';
|
|||
import InputHint from '../../components/InputHint/InputHint';
|
||||
import validate from '../../../modules/validate';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
import './Profile.scss';
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ class Profile extends React.Component {
|
|||
|
||||
Meteor.call('users.editProfile', profile, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Bert.alert(this.t("¡Perfíl actualizado!"), 'success');
|
||||
}
|
||||
|
|
@ -106,7 +107,7 @@ class Profile extends React.Component {
|
|||
if (this.newPassword.value) {
|
||||
Accounts.changePassword(this.currentPassword.value, this.newPassword.value, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
this.currentPassword.value = '';
|
||||
this.newPassword.value = '';
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Bert } from 'meteor/themeteorchef:bert';
|
|||
import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter';
|
||||
import validate from '../../../modules/validate';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
class RecoverPassword extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -28,8 +29,8 @@ class RecoverPassword extends React.Component {
|
|||
},
|
||||
messages: {
|
||||
emailAddress: {
|
||||
required: 'Need an email address here.',
|
||||
email: 'Is this email address correct?',
|
||||
required: this.t("Necesitamos un correo aquí."),
|
||||
email: this.t("¿Es este correo correcto?"),
|
||||
},
|
||||
},
|
||||
submitHandler() { component.handleSubmit(); },
|
||||
|
|
@ -43,7 +44,7 @@ class RecoverPassword extends React.Component {
|
|||
|
||||
Accounts.forgotPassword({ email, t }, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Bert.alert(t("checkResetEmail", {email: email}), 'success');
|
||||
history.push('/login');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { Accounts } from 'meteor/accounts-base';
|
|||
import { Bert } from 'meteor/themeteorchef:bert';
|
||||
import validate from '../../../modules/validate';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
class ResetPassword extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -50,7 +51,7 @@ class ResetPassword extends React.Component {
|
|||
|
||||
Accounts.resetPassword(token, this.newPassword.value, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
history.push('/documents');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import validate from '../../../modules/validate';
|
|||
import Icon from '../../components/Icon/Icon';
|
||||
import './Signup.scss';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
class Signup extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -43,18 +44,18 @@ class Signup extends React.Component {
|
|||
},
|
||||
messages: {
|
||||
firstName: {
|
||||
required: 'What\'s your first name?',
|
||||
required: this.t("¿Cuál es tu nombre?"),
|
||||
},
|
||||
lastName: {
|
||||
required: 'What\'s your last name?',
|
||||
required: this.t("¿Cuál es tu apellido?"),
|
||||
},
|
||||
emailAddress: {
|
||||
required: 'Need an email address here.',
|
||||
email: 'Is this email address correct?',
|
||||
required: this.t("Necesitamos una contraseña aquí."),
|
||||
email: this.t("¿Es correcto este correo?"),
|
||||
},
|
||||
password: {
|
||||
required: 'Need a password here.',
|
||||
minlength: 'Please use at least six characters.',
|
||||
required: this.t("Necesitamos una contraseña aquí."),
|
||||
minlength: this.t("Usa al menos seis caracteres."),
|
||||
},
|
||||
},
|
||||
submitHandler() { component.handleSubmit(); },
|
||||
|
|
@ -75,7 +76,7 @@ class Signup extends React.Component {
|
|||
},
|
||||
}, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Meteor.call('users.sendVerificationEmail');
|
||||
Bert.alert('Welcome!', 'success');
|
||||
|
|
@ -90,13 +91,13 @@ class Signup extends React.Component {
|
|||
<Col xs={12} sm={6} md={5} lg={4}>
|
||||
<h4 className="page-header">{this.t("Registrarse")}</h4>
|
||||
<Row>
|
||||
<Col xs={12}>
|
||||
<button
|
||||
className={`btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram`}
|
||||
type="button" onClick={() => handleLogin(service, callback)}>
|
||||
<span><Icon icon="telegram" /> Usa nuestro bot de Telegram</span>
|
||||
</button>
|
||||
</Col>
|
||||
{/* <Col xs={12}>
|
||||
<button
|
||||
className={`btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram`}
|
||||
type="button" onClick={() => handleLogin(service, callback)}>
|
||||
<span><Icon icon="telegram" /> Usa nuestro bot de Telegram</span>
|
||||
</button>
|
||||
</Col> */}
|
||||
<Col xs={12}>
|
||||
<OAuthLoginButtons
|
||||
services={['telegram', 'google']}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Meteor } from 'meteor/meteor';
|
|||
import { Accounts } from 'meteor/accounts-base';
|
||||
import { Bert } from 'meteor/themeteorchef:bert';
|
||||
import { translate } from 'react-i18next';
|
||||
import { T9n } from 'meteor-accounts-t9n';
|
||||
|
||||
class VerifyEmail extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -17,7 +18,7 @@ class VerifyEmail extends React.Component {
|
|||
const { match, history } = this.props;
|
||||
Accounts.verifyEmail(match.params.token, (error) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
this.setState({ error: error.reason + ". " + this.t("Por favor, inténtalo otra vez.")});
|
||||
// this.setState({ error: `${error.reason}. Please try again.` });
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
"jquery-validation": "^1.17.0",
|
||||
"juice": "^4.1.1",
|
||||
"lodash": "^4.17.4",
|
||||
"meteor-accounts-t9n": "^2.0.3",
|
||||
"meteor-node-stubs": "^0.2.11",
|
||||
"moment": "^2.19.2",
|
||||
"popper.js": "^1.12.7",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"Licencia": "License",
|
||||
"Cerrar sesión": "Logout",
|
||||
"Registrarse": "Sign Up",
|
||||
"Regístrate": "Sign Up",
|
||||
"Iniciar sesión": "Login",
|
||||
"o regístrate con un correo": "or Sign Up with an Email Address",
|
||||
"o inicia sesión con un correo":
|
||||
|
|
@ -30,7 +31,7 @@
|
|||
"Use at least six characters.",
|
||||
"Iniciar sesión con Google":
|
||||
"Log In with Google",
|
||||
"¿Olvidaste tu contraseña":
|
||||
"¿Olvidaste tu contraseña?":
|
||||
"Forgot password?",
|
||||
"¿No tienes una cuenta?":
|
||||
"Don't have an account?",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"Licencia": "Licencia",
|
||||
"Cerrar sesión": "Cerrar sesión",
|
||||
"Registrarse": "Registrarse",
|
||||
"Regístrate": "Regístrate",
|
||||
"Iniciar sesión": "Iniciar sesión",
|
||||
"o regístrate con un correo":
|
||||
"o regístrate con un correo",
|
||||
|
|
@ -31,8 +32,8 @@
|
|||
"Usa al menos seis caracteres.",
|
||||
"Iniciar sesión con Google":
|
||||
"Iniciar sesión con Google",
|
||||
"¿Olvidaste tu contraseña":
|
||||
"¿Olvidaste tu contraseña",
|
||||
"¿Olvidaste tu contraseña?":
|
||||
"¿Olvidaste tu contraseña?",
|
||||
"¿No tienes una cuenta?":
|
||||
"¿No tienes una cuenta?",
|
||||
"Introduce tu correo abajo para recibir un enlace para resetear tu contraseña.":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue