diff --git a/README.md b/README.md
index 3c618bb..07c2bea 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Run ```npm install``` to download all the dependencies
* To generate production code, run ```npm run build```
#### TODO LIST
-- [ ] Add multilanguage
+- [X] Add multilanguage
- [ ] Show load on fetch times
- [ ] Update webpack
- [X] Publish --> Add ccs
diff --git a/package.json b/package.json
index d6de66f..a99b50b 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,9 @@
"repository": "git@github.com/Salec/SDRBuses.git",
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
- "build": "webpack -p --config ./webpack.prod.js --define process.env.NODE_ENV='\"production\"' --progress --colors --display-modules"
+ "build": "webpack -p --config ./webpack.prod.js --define process.env.NODE_ENV='\"production\"' --progress --colors --display-modules",
+ "extract": "i18n_extract",
+ "import": "i18n_import --translations=src/translations"
},
"license": "MIT",
"devDependencies": {
@@ -38,6 +40,7 @@
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"redux-form": "^4.1.3",
+ "redux-i18n": "^1.5.11",
"redux-promise": "^0.5.3",
"underscore": "^1.8.3"
}
diff --git a/src/components/about.js b/src/components/about.js
index 8b484a3..b64cef4 100644
--- a/src/components/about.js
+++ b/src/components/about.js
@@ -1,23 +1,21 @@
-/**
- * Created by Fernando on 13/11/2017.
- */
import React, {Component} from 'react';
+import PropTypes from 'prop-types';
export default class About extends Component {
render() {
return (
-
Sobre esta página
-
- Proyecto de código abierto creado por Fernando Martín usando técnologias de react y redux
+
{this.context.t("About this page")}
+
{this.context.t("Open source project created by Fernando Martín García usign react and redux tecnologies")}
-
Puedes contribuir con el projecto en github:
+
{this.context.t("You can collaborate with the project in github:")}
@@ -26,7 +24,7 @@ export default class About extends Component {
- Actuales Colaboradores
+ {this.context.t("Current Colaborators")}
@@ -38,7 +36,8 @@ export default class About extends Component {
alt="Fernando Martín García"/>
Fernando Martín García
-
+
-
+
-
Tu nombre aquí
-
+ {this.context.t("Your name here")}
+
);
}
+}
+About.contextTypes = {
+ t: PropTypes.func
}
\ No newline at end of file
diff --git a/src/components/app.js b/src/components/app.js
index dd84ff9..26be8e9 100644
--- a/src/components/app.js
+++ b/src/components/app.js
@@ -1,9 +1,11 @@
import React, {Component} from 'react';
+import I18n from "redux-i18n";
import Main from './main'
+import {translations} from '../translations/translations';
const App = () => (
-
+
-
+
);
export default App
\ No newline at end of file
diff --git a/src/components/buses_lines.js b/src/components/buses_lines.js
index ed03315..6000d9d 100644
--- a/src/components/buses_lines.js
+++ b/src/components/buses_lines.js
@@ -1,18 +1,14 @@
-/**
- * Created by Fernando on 4/10/2017.
- */
import _ from 'underscore';
import React, {Component} from 'react';
import {connect} from 'react-redux';
+import PropTypes from 'prop-types';
import {fecthListBuses} from '../actions/index';
-
class BusLines extends Component {
constructor(props) {
super(props);
-
- this.state = { isOpen: false };
+ this.state = {isOpen: false};
}
toggleModal = () => {
@@ -35,24 +31,23 @@ class BusLines extends Component {
})
}
- goto = (event) =>{
+ goto = (event) => {
this.props.history.push(event.target.parentElement.dataset.url)
}
render() {
if (!this.props.lines) {
- return
Cargando...
+ return
{this.context.t("Loading...")}
}
-
return (
-
Índice de líneas
+
{this.context.t("Line Index")}
- Nombre |
- Linea |
+ {this.context.t("Name")} |
+ {this.context.t("Line")} |
@@ -65,18 +60,18 @@ class BusLines extends Component {
};
componentWillMount() {
-
this.props.fecthListBuses();
};
}
-
+BusLines.contextTypes = {
+ t: PropTypes.func
+}
function mapStateToProps(state) {
- let order = _.sortBy(state.lines.busLines.resources, info =>{
+ let order = _.sortBy(state.lines.busLines.resources, info => {
return parseInt(info['dc:identifier']);
});
return {lines: order};
}
-
export default connect(mapStateToProps, {fecthListBuses})(BusLines);
\ No newline at end of file
diff --git a/src/components/languageSelector.js b/src/components/languageSelector.js
new file mode 100644
index 0000000..dbd1668
--- /dev/null
+++ b/src/components/languageSelector.js
@@ -0,0 +1,22 @@
+import React, {Component} from 'react';
+import {connect} from 'react-redux';
+import {setLanguage} from "redux-i18n";
+
+class LanguageSelector extends Component {
+ render() {
+ return (
+
+ );
+ }
+}
+export default connect(state => ({
+ lang: state.i18nState.lang,
+}))(LanguageSelector)
\ No newline at end of file
diff --git a/src/components/modal.js b/src/components/modal.js
index db6d094..9f9d21d 100644
--- a/src/components/modal.js
+++ b/src/components/modal.js
@@ -7,6 +7,7 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {orderTimes} from '../auxFunctions/common';
import _ from 'underscore';
+import PropTypes from 'prop-types';
export const MODAL_ID = 'myModal';
@@ -19,7 +20,8 @@ class Modal extends Component {
-
Tiempo Parada {this.props.stop} - {this.props.name}
+ {this.context.t("Time for stop ")} {this.props.stop} -
+ {this.props.name}
@@ -63,13 +65,17 @@ class Modal extends Component {
}
}
-
- }
+
+}
+Modal.contextTypes = {
+ t: PropTypes.func
+}
function mapsStateToProps(state) {
- return {time: state.lines.time,
- stop: state.lines.stop,
- name: state.lines.name
- }
+ return {
+ time: state.lines.time,
+ stop: state.lines.stop,
+ name: state.lines.name
+ }
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({fetchTimes: fetchTimes}, dispatch)
diff --git a/src/components/navegation.js b/src/components/navegation.js
index 23f5c59..0af96d3 100644
--- a/src/components/navegation.js
+++ b/src/components/navegation.js
@@ -1,54 +1,81 @@
import React from 'react';
-import { withRouter } from 'react-router-dom';
+import {withRouter} from 'react-router-dom';
import {connect} from 'react-redux';
import {changeStop} from '../actions/index';
+import LanguageSelector from "./languageSelector"
+import PropTypes from 'prop-types';
+
const SCHEDULE = "http://www.tusantander.es/sites/tus.int.ayto-santander.es/files/tusinvierno2017_optimizado.pdf";
const MAP = "http://www.tusantander.es/sites/tus.int.ayto-santander.es/files/planos-red-lineas_1.pdf";
class Nav extends React.Component {
render() {
return (
-