From 121725c037b2bccad3db7dc4f4d1f9140efc7839 Mon Sep 17 00:00:00 2001 From: Juan Carlos Farah Date: Tue, 2 Jul 2019 12:15:35 +0200 Subject: [PATCH] fix: update translations closes #120 --- src/components/LoadSpace.js | 27 ++++++++++++--------- src/components/VisitSpace.js | 13 ++++++---- src/components/phase/Phase.js | 2 -- src/components/space/SpaceDescription.js | 12 +++------- src/components/space/SpaceGrid.js | 12 ++++++---- src/langs/en.json | 22 ++++++++++++++++- src/langs/fr.json | 30 ++++++++++++++++++++---- 7 files changed, 82 insertions(+), 36 deletions(-) diff --git a/src/components/LoadSpace.js b/src/components/LoadSpace.js index afeebf73..d1e068b4 100644 --- a/src/components/LoadSpace.js +++ b/src/components/LoadSpace.js @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import Typography from '@material-ui/core/Typography/Typography'; import { withStyles } from '@material-ui/core/styles'; +import { withTranslation } from 'react-i18next'; import Drawer from '@material-ui/core/Drawer'; import CssBaseline from '@material-ui/core/CssBaseline'; import AppBar from '@material-ui/core/AppBar'; @@ -34,6 +35,7 @@ class LoadSpace extends Component { }; static propTypes = { + t: PropTypes.func.isRequired, dispatchLoadSpace: PropTypes.func.isRequired, theme: PropTypes.shape({ direction: PropTypes.string.isRequired }) .isRequired, @@ -80,7 +82,7 @@ class LoadSpace extends Component { }; render() { - const { classes, theme, activity } = this.props; + const { classes, theme, activity, t } = this.props; const { open, fileLocation } = this.state; if (activity) { @@ -145,7 +147,7 @@ class LoadSpace extends Component {
- Load a Space from a File + {t('Load a Space')} - Load + {t('Load')} @@ -190,11 +192,14 @@ const mapStateToProps = ({ Space }) => ({ activity: Space.get('current').get('activity'), }); -export default withRouter( - withStyles(Styles, { withTheme: true })( - connect( - mapStateToProps, - mapDispatchToProps - )(LoadSpace) - ) +const ConnectedComponent = connect( + mapStateToProps, + mapDispatchToProps +)(LoadSpace); + +const TranslatedComponent = withTranslation()(ConnectedComponent); + +const StyledComponent = withStyles(Styles, { withTheme: true })( + TranslatedComponent ); +export default withRouter(StyledComponent); diff --git a/src/components/VisitSpace.js b/src/components/VisitSpace.js index 7d7ca824..6df94377 100644 --- a/src/components/VisitSpace.js +++ b/src/components/VisitSpace.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'; import { withRouter } from 'react-router'; import classNames from 'classnames'; import { withStyles } from '@material-ui/core/styles'; +import { withTranslation } from 'react-i18next'; import { connect } from 'react-redux'; import Drawer from '@material-ui/core/Drawer'; import CssBaseline from '@material-ui/core/CssBaseline'; @@ -35,6 +36,7 @@ class VisitSpace extends Component { }; static propTypes = { + t: PropTypes.func.isRequired, classes: PropTypes.shape({}).isRequired, theme: PropTypes.shape({}).isRequired, activity: PropTypes.bool, @@ -83,7 +85,7 @@ class VisitSpace extends Component { }; render() { - const { classes, theme, activity } = this.props; + const { classes, theme, activity, t } = this.props; const { open, spaceId } = this.state; if (activity) { @@ -149,7 +151,7 @@ class VisitSpace extends Component {
- Visit a Space + {t('Visit a Space')} - Visit + {t('Visit')} @@ -184,7 +186,10 @@ const mapStateToProps = ({ Space }) => ({ }); const ConnectedComponent = connect(mapStateToProps)(VisitSpace); + +const TranslatedComponent = withTranslation()(ConnectedComponent); + const StyledComponent = withStyles(Styles, { withTheme: true })( - ConnectedComponent + TranslatedComponent ); export default withRouter(StyledComponent); diff --git a/src/components/phase/Phase.js b/src/components/phase/Phase.js index 9d9b5f73..a1c0f000 100644 --- a/src/components/phase/Phase.js +++ b/src/components/phase/Phase.js @@ -38,7 +38,6 @@ class Phase extends Component { const { phase, space, dispatchSelectPhase, start } = this.props; const phases = space.get('phases'); const saved = space.get('saved'); - const lang = space.get('language'); const description = space.get('description'); if (!phase || phase.isEmpty()) { return ( @@ -47,7 +46,6 @@ class Phase extends Component { description={description} selectPhase={dispatchSelectPhase} start={start} - lang={lang} saved={saved} /> ); diff --git a/src/components/space/SpaceDescription.js b/src/components/space/SpaceDescription.js index 2346c45a..a5b1259e 100644 --- a/src/components/space/SpaceDescription.js +++ b/src/components/space/SpaceDescription.js @@ -5,7 +5,6 @@ import { Typography, withStyles } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; import Styles from '../../Styles'; import './SpaceDescription.css'; -import { DEFAULT_LANGUAGE } from '../../config/constants'; import Banner from '../common/Banner'; const renderPreviewWarning = t => { @@ -13,18 +12,15 @@ const renderPreviewWarning = t => { ); }; -const SpaceDescription = ({ description, classes, start, lang, saved }) => { - const { i18n } = useTranslation(); +const SpaceDescription = ({ description, classes, start, saved }) => { + const { t } = useTranslation(); - // we use the fixed translation for spaces as they - // are meant to be consumed in the predefined language - const t = i18n.getFixedT(lang); return (
@@ -49,14 +45,12 @@ const SpaceDescription = ({ description, classes, start, lang, saved }) => { SpaceDescription.propTypes = { description: PropTypes.string.isRequired, - lang: PropTypes.string, classes: PropTypes.shape({ appBar: PropTypes.string.isRequired }).isRequired, start: PropTypes.func.isRequired, saved: PropTypes.bool, }; SpaceDescription.defaultProps = { - lang: DEFAULT_LANGUAGE, saved: false, }; diff --git a/src/components/space/SpaceGrid.js b/src/components/space/SpaceGrid.js index 357eae84..b421987d 100644 --- a/src/components/space/SpaceGrid.js +++ b/src/components/space/SpaceGrid.js @@ -6,6 +6,7 @@ import RemoveRedEyeIcon from '@material-ui/icons/RemoveRedEye'; import Button from '@material-ui/core/Button/Button'; import { withStyles } from '@material-ui/core'; import { withRouter } from 'react-router'; +import { withTranslation } from 'react-i18next'; import Typography from '@material-ui/core/Typography/Typography'; import Grid from '@material-ui/core/Grid/Grid'; import MediaCard from '../common/MediaCard'; @@ -32,6 +33,7 @@ class SpaceGrid extends Component { history: PropTypes.shape({ length: PropTypes.number.isRequired }) .isRequired, dispatchClearSpace: PropTypes.func.isRequired, + t: PropTypes.func.isRequired, saved: PropTypes.bool, }; @@ -80,7 +82,7 @@ class SpaceGrid extends Component { }; render() { - const { spaces, classes, history, saved } = this.props; + const { spaces, classes, history, saved, t } = this.props; // spaces is a set to mapping through it will return a set const MediaCards = spaces.map(space => { @@ -96,7 +98,7 @@ class SpaceGrid extends Component { fullWidth > - View + {t('View')} ); return ( @@ -115,7 +117,7 @@ class SpaceGrid extends Component { if (!MediaCards.size) { return ( - No spaces available. + {t('No Spaces Available')} ); } @@ -140,4 +142,6 @@ const ConnectedComponent = connect( mapDispatchToProps )(SpaceGrid); -export default withRouter(withStyles(SpaceGrid.styles)(ConnectedComponent)); +const TranslatedComponent = withTranslation()(ConnectedComponent); + +export default withRouter(withStyles(SpaceGrid.styles)(TranslatedComponent)); diff --git a/src/langs/en.json b/src/langs/en.json index 31cc185e..1748d378 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -10,6 +10,26 @@ "Developer": "Developer", "Danger Zone! Proceed with caution as changes to this section might lead to data loss.": "Danger Zone! Proceed with caution as changes to this section might lead to data loss.", "Manually Edit the Database": "Manually Edit the Database", - "Use Sample Database": "Use Sample Database" + "Use Sample Database": "Use Sample Database", + "Developer Mode": "Developer Mode", + "Load a Space": "Load a Space", + "View": "View", + "Open": "Open", + "Browse": "Browse", + "Visit": "Visit", + "No Spaces Available": "No Spaces Available", + "Preview": "Preview", + "You are previewing this space. Any input or changes will not be saved.": "You are previewing this space. Any input or changes will not be saved.", + "Save this space for offline use.": "Save this space for offline use.", + "This space requires an internet connection.": "This space requires an internet connection.", + "Delete this space.": "Delete this space.", + "Export this space to share with others.": "Export this space to share with others.", + "Synchronize this space with its online version. All user input will be deleted.": "Synchronize this space with its online version. All user input will be deleted.", + "Delete": "Delete", + "Are you sure you want to delete this space?": "Are you sure you want to delete this space?", + "Sync": "Sync", + "Save As": "Save As", + "Cancel": "Cancel", + "Are you sure you want to sync this space? All user input will be deleted.": "Are you sure you want to sync this space? All user input will be deleted." } } diff --git a/src/langs/fr.json b/src/langs/fr.json index f02e9191..76b1e8fe 100644 --- a/src/langs/fr.json +++ b/src/langs/fr.json @@ -1,15 +1,35 @@ { "translations": { - "Settings": "Réglages", + "Settings": "Paramètres", "Language": "Langue", - "Saved Spaces": "Espaces Sauvegardés", + "Saved Spaces": "Espaces Enregistrés", "Spaces Nearby": "Espaces à Proximité", "Visit a Space": "Visiter un Espace", - "Load": "Charger un Espace", + "Load": "Charger", "Start": "Démarrer", "Developer": "Développeur", - "Danger Zone! Proceed with caution as changes to this section might lead to data loss.": "Attention ! Les changements que vous faites ici peuvent causer la parte de données.", + "Danger Zone! Proceed with caution as changes to this section might lead to data loss.": "Attention ! Les modifications de cette section pourraient entraîner une perte de données.", "Manually Edit the Database": "Modifier Manuellement la Base de Données", - "Use Sample Database": "Utiliser une Base de Données Exemple" + "Use Sample Database": "Utiliser une Base de Données Exemple", + "Developer Mode": "Mode Développeur", + "Load a Space": "Charger un Espace", + "View": "Voir", + "Open": "Ouvrir", + "Browse": "Parcourir", + "Visit": "Visiter", + "No Spaces Available": "Aucun Espace Disponible", + "Preview": "Tester", + "You are previewing this space. Any input or changes will not be saved.": "Vous testez cet espace. Toute entrée ou modification ne sera pas sauvegardée.", + "Save this space for offline use.": "Enregistrer cet espace pour une utilisation hors connexion.", + "This space requires an internet connection.": "Cet espace nécessite une connexion internet.", + "Delete this space.": "Supprimer cet espace.", + "Export this space to share with others.": "Exporter cet espace pour le partager.", + "Synchronize this space with its online version. All user input will be deleted.": "Synchroniser cet espace avec sa version en ligne. Toute entrée utilisateur sera supprimée.", + "Delete": "Supprimer", + "Are you sure you want to delete this space?": "Êtes-vous sûr de vouloir supprimer cet espace?", + "Sync": "Synchroniser", + "Save As": "Enregistrer Sous", + "Cancel": "Annuler", + "Are you sure you want to sync this space? All user input will be deleted.": "Êtes-vous sur de vouloir synchroniser cet espace? Toute entrée utilisateur sera supprimée." } }