# HG changeset patch # User ymh # Date 1541689408 -3600 # Node ID 03334a31130a82c59ddfdc3949a94d987cd09aa0 # Parent 7da1d5137b0ba7403f87622a6f8874d345173fd8 Add translation with react-i18next diff -r 7da1d5137b0b -r 03334a31130a client/package.json --- a/client/package.json Tue Nov 06 16:19:26 2018 +0100 +++ b/client/package.json Thu Nov 08 16:03:28 2018 +0100 @@ -11,6 +11,7 @@ "bootstrap": "^4.1.3", "connected-react-router": "^4.5.0", "i18next": "^11.6.0", + "i18next-browser-languagedetector": "^2.2.3", "immutable": "^3.8.2", "jquery": "^3.3.1", "jwt-decode": "^2.2.0", @@ -19,10 +20,12 @@ "moment": "^2.18.1", "npm": "^6.4.1", "popper.js": "^1.14.4", + "prop-types": "^15.6.2", "qs": "^6.5.0", "ramda": "^0.25.0", "react": "^16.5.2", "react-dom": "^16.5.2", + "react-i18next": "^8.3.6", "react-modal": "^3.5.1", "react-overlays": "^0.8.3", "react-portal": "^4.1.5", diff -r 7da1d5137b0b -r 03334a31130a client/src/components/CreateGroup.js --- a/client/src/components/CreateGroup.js Tue Nov 06 16:19:26 2018 +0100 +++ b/client/src/components/CreateGroup.js Thu Nov 08 16:03:28 2018 +0100 @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { Trans } from 'react-i18next'; import '../App.css'; import Navbar from './Navbar'; import * as authActions from '../actions/authActions'; @@ -79,22 +80,22 @@
-
Nouveau groupe
+
nouveau groupe
- + {/* { this.renderErrorMessage(errorMessages, 'name') } */}
- + {/* { this.renderErrorMessage(errorMessages, 'description') } */}
{/* { this.renderNonFieldErrors(errorMessages) } */}
- - + +
diff -r 7da1d5137b0b -r 03334a31130a client/src/components/CreateSession.js --- a/client/src/components/CreateSession.js Tue Nov 06 16:19:26 2018 +0100 +++ b/client/src/components/CreateSession.js Thu Nov 08 16:03:28 2018 +0100 @@ -2,10 +2,11 @@ import Modal from 'react-modal'; import PropTypes from 'prop-types'; import uuidV1 from 'uuid/v1'; +import { withNamespaces } from 'react-i18next'; import '../App.css'; import './CreateSession.css'; -export default class CreateSession extends Component { +class CreateSession extends Component { static propTypes = { history: PropTypes.object.isRequired, @@ -69,9 +70,10 @@ render() { + const t = this.props.t; return (
- Nouvelle session + {t('create_session.new_session')}
{ e.preventDefault() } }>
- +
- +
- +
{/*
{JSON.stringify(this.props.currentSession.protocol, null, 2)}
*/}
{JSON.stringify(this.getGroupProtocol(), null, 2)}
- +
@@ -116,3 +118,5 @@ ); } } + +export default withNamespaces()(CreateSession); diff -r 7da1d5137b0b -r 03334a31130a client/src/components/Login.js --- a/client/src/components/Login.js Tue Nov 06 16:19:26 2018 +0100 +++ b/client/src/components/Login.js Thu Nov 08 16:03:28 2018 +0100 @@ -1,6 +1,8 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { Trans } from 'react-i18next'; + import '../App.css'; import './Login.css'; // import Navbar from './Navbar'; @@ -51,17 +53,26 @@ } renderNonFieldErrors(errorMessages) { - console.log(errorMessages); + + if (errorMessages && errorMessages.error) { + return ( +
+ Unable to log in. +
+ ) + } + const errors = R.path(['data','non_field_errors'], errorMessages); if (errors) { return ( -
+
{ errors.map((message, key) => -

{ message }

+

{ message }

) }
) } + } render() { @@ -79,24 +90,24 @@

IRI Notes

- + {/* { this.renderErrorMessage(errorMessages, 'username') } */}
- + {/* { this.renderErrorMessage(errorMessages, 'password') } */}
{ this.renderNonFieldErrors(errorMessages) }
- +

- Pas encore inscrit ? Créer un compte. + Pas encore inscrit ? Créer un compte.

diff -r 7da1d5137b0b -r 03334a31130a client/src/components/Navbar.js --- a/client/src/components/Navbar.js Tue Nov 06 16:19:26 2018 +0100 +++ b/client/src/components/Navbar.js Thu Nov 08 16:03:28 2018 +0100 @@ -5,6 +5,8 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import { bindActionCreators } from 'redux'; +import { withNamespaces, Trans } from 'react-i18next'; + // import logo from './logo.svg'; import Modal from 'react-modal'; import * as authActions from '../actions/authActions'; @@ -60,8 +62,7 @@ const OffLineMessage = ({isAuthenticated}) => { if (!isAuthenticated) { return ( - Vous êtes en mode Offline. N'oubliez pas de - vous connecter ou de créer un compte pour sauvegarder vos sessions + ); } return ( @@ -146,6 +147,7 @@ } render() { + const t = this.props.t; return (