Skip to content

Commit

Permalink
fix: update translations
Browse files Browse the repository at this point in the history
closes #120
  • Loading branch information
juancarlosfarah committed Jul 2, 2019
1 parent 58ae1f4 commit 121725c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 36 deletions.
27 changes: 16 additions & 11 deletions src/components/LoadSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -145,15 +147,15 @@ class LoadSpace extends Component {
<div className={classes.drawerHeader} />
<FormControl className={classes.formControl}>
<Typography variant="h4" color="inherit" style={{ margin: '2rem' }}>
Load a Space from a File
{t('Load a Space')}
</Typography>
<Button
variant="contained"
onClick={this.handleBrowse}
color="primary"
className={classes.button}
>
Browse
{t('Browse')}
</Button>
<Input
required
Expand All @@ -173,7 +175,7 @@ class LoadSpace extends Component {
className={classes.button}
disabled={!fileLocation.endsWith('.zip')}
>
Load
{t('Load')}
</Button>
</FormControl>
</main>
Expand All @@ -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);
13 changes: 9 additions & 4 deletions src/components/VisitSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -149,7 +151,7 @@ class VisitSpace extends Component {
<div className={classes.drawerHeader} />
<FormControl className={classes.formControl}>
<Typography variant="h4" color="inherit" style={{ margin: '2rem' }}>
Visit a Space
{t('Visit a Space')}
</Typography>
<Input
className={classes.input}
Expand All @@ -170,7 +172,7 @@ class VisitSpace extends Component {
className={classes.button}
disabled={!window.navigator.onLine || !spaceId || spaceId === ''}
>
Visit
{t('Visit')}
</Button>
</FormControl>
</main>
Expand All @@ -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);
2 changes: 0 additions & 2 deletions src/components/phase/Phase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -47,7 +46,6 @@ class Phase extends Component {
description={description}
selectPhase={dispatchSelectPhase}
start={start}
lang={lang}
saved={saved}
/>
);
Expand Down
12 changes: 3 additions & 9 deletions src/components/space/SpaceDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@ 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 => {
return (
<Banner
type="warning"
text={t(
'Warning: 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.'
)}
/>
);
};

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 (
<div className="SpaceDescription">
<div>
Expand All @@ -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,
};

Expand Down
12 changes: 8 additions & 4 deletions src/components/space/SpaceGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
};

Expand Down Expand Up @@ -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 => {
Expand All @@ -96,7 +98,7 @@ class SpaceGrid extends Component {
fullWidth
>
<RemoveRedEyeIcon className={classes.leftIcon} />
View
{t('View')}
</Button>
);
return (
Expand All @@ -115,7 +117,7 @@ class SpaceGrid extends Component {
if (!MediaCards.size) {
return (
<Typography variant="h5" color="inherit">
No spaces available.
{t('No Spaces Available')}
</Typography>
);
}
Expand All @@ -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));
22 changes: 21 additions & 1 deletion src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
30 changes: 25 additions & 5 deletions src/langs/fr.json
Original file line number Diff line number Diff line change
@@ -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."
}
}

0 comments on commit 121725c

Please sign in to comment.