From 9694719e0273f0af78605dcfa1dbcb962a8e1c53 Mon Sep 17 00:00:00 2001 From: ov Date: Wed, 12 Aug 2020 15:24:29 +0100 Subject: [PATCH] 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 --- client/components/Nav.jsx | 6 +-- client/modules/User/components/LoginForm.jsx | 18 +++++---- .../User/components/SocialAuthButton.jsx | 22 ++++++----- client/modules/User/pages/LoginView.jsx | 23 ++++++----- translations/locales/en-US/translations.json | 38 +++++++++++++------ translations/locales/es-419/translations.json | 38 +++++++++++++------ 6 files changed, 91 insertions(+), 54 deletions(-) diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index 16617112..4f315bb3 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -608,13 +608,13 @@ class Nav extends React.PureComponent { diff --git a/client/modules/User/components/LoginForm.jsx b/client/modules/User/components/LoginForm.jsx index 9cc85d98..51115e5f 100644 --- a/client/modules/User/components/LoginForm.jsx +++ b/client/modules/User/components/LoginForm.jsx @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; - +import { withTranslation } from 'react-i18next'; +import i18n from 'i18next'; import Button from '../../../common/Button'; import { domOnlyProps } from '../../../utils/reduxFormUtils'; @@ -12,10 +13,10 @@ function LoginForm(props) { return (

- + {email.error}}

- + Log In + >{props.t('LoginForm.Submit')}

); @@ -52,7 +53,8 @@ LoginForm.propTypes = { submitting: PropTypes.bool, pristine: PropTypes.bool, invalid: PropTypes.bool, - previousPath: PropTypes.string.isRequired + previousPath: PropTypes.string.isRequired, + t: PropTypes.func.isRequired }; LoginForm.defaultProps = { @@ -61,4 +63,4 @@ LoginForm.defaultProps = { invalid: false }; -export default LoginForm; +export default withTranslation()(LoginForm); diff --git a/client/modules/User/components/SocialAuthButton.jsx b/client/modules/User/components/SocialAuthButton.jsx index afcb605d..62bf4097 100644 --- a/client/modules/User/components/SocialAuthButton.jsx +++ b/client/modules/User/components/SocialAuthButton.jsx @@ -1,6 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import styled from 'styled-components'; +import i18n from 'i18next'; +import { withTranslation } from 'react-i18next'; import { remSize } from '../../../theme'; @@ -12,11 +14,6 @@ const authUrls = { google: '/auth/google' }; -const labels = { - github: 'Login with GitHub', - google: 'Login with Google' -}; - const icons = { github: GithubIcon, google: GoogleIcon @@ -31,11 +28,15 @@ const StyledButton = styled(Button)` width: ${remSize(300)}; `; -function SocialAuthButton({ service }) { +function SocialAuthButton({ service, t }) { const ServiceIcon = icons[service]; + const labels = { + github: t('SocialAuthButton.Github'), + google: t('SocialAuthButton.Google') + }; return ( } + iconBefore={} href={authUrls[service]} > {labels[service]} @@ -46,7 +47,10 @@ function SocialAuthButton({ service }) { SocialAuthButton.services = services; SocialAuthButton.propTypes = { - service: PropTypes.oneOf(['github', 'google']).isRequired + service: PropTypes.oneOf(['github', 'google']).isRequired, + t: PropTypes.func.isRequired }; -export default SocialAuthButton; +const SocialAuthButtonPublic = withTranslation()(SocialAuthButton); +SocialAuthButtonPublic.services = services; +export default SocialAuthButtonPublic; diff --git a/client/modules/User/pages/LoginView.jsx b/client/modules/User/pages/LoginView.jsx index 84e3c4c9..20b48b17 100644 --- a/client/modules/User/pages/LoginView.jsx +++ b/client/modules/User/pages/LoginView.jsx @@ -3,6 +3,8 @@ import React from 'react'; import { reduxForm } from 'redux-form'; import { Link, browserHistory } from 'react-router'; import { Helmet } from 'react-helmet'; +import { withTranslation } from 'react-i18next'; +import i18n from 'i18next'; import { validateAndLoginUser } from '../actions'; import LoginForm from '../components/LoginForm'; import { validateLogin } from '../../../utils/reduxFormUtils'; @@ -34,23 +36,23 @@ class LoginView extends React.Component {