diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 000000000..6ce752776 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,3 @@ +{ + "news":"Welcome to the english-language version of the salary cost estimator" +} diff --git a/package.json b/package.json index 2a408f0b6..5e8414165 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "not ie < 11" ], "dependencies": { - "live-server": "^1.2.0", "@babel/polyfill": "^7.0.0-beta.34", "classnames": "^2.2.5", "dedent-js": "^1.0.1", @@ -24,8 +23,11 @@ "fuse.js": "^3.2.0", "global": "^4.3.2", "google-translate-api": "^2.3.0", + "i18next": "^10.0.7", + "i18next-xhr-backend": "^1.5.1", "ignore-loader": "^0.1.2", "js-yaml": "^3.9.1", + "live-server": "^1.2.0", "marked": "^0.3.9", "mocha": "^5.0.0", "mocha-webpack": "^1.0.1", @@ -38,6 +40,7 @@ "react-dom": "^16.2.0", "react-helmet": "^5.2.0", "react-highlight-words": "^0.10.0", + "react-i18next": "^7.5.0", "react-redux": "^5.0.6", "react-router": "^4.2.0", "react-router-dom": "^4.2.2", diff --git a/source/components/pages/Home.js b/source/components/pages/Home.js index ef6439e23..6a58fcee2 100644 --- a/source/components/pages/Home.js +++ b/source/components/pages/Home.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import { Trans } from 'react-i18next' import './Pages.css' import './Home.css' import TargetSelection from '../TargetSelection' @@ -28,8 +29,10 @@ export default class Home extends Component { }} />

+ Cette nouvelle version du site vous permet de simuler un CDD ou CDI, aux taux de 2018. +

diff --git a/source/containers/Layout.js b/source/containers/Layout.js index 0018a28ed..dec128263 100644 --- a/source/containers/Layout.js +++ b/source/containers/Layout.js @@ -1,3 +1,7 @@ +import { I18nextProvider } from 'react-i18next'; +import i18next from 'i18next' +import XHR from 'i18next-xhr-backend'; + import React, { Component } from 'react' import './Layout.css' import './reset.css' @@ -19,6 +23,29 @@ import createHistory from 'history/createBrowserHistory' import { Header, Footer } from 'Components/pages/Header' import { getIframeOption } from '../utils' +function loadLocales(url, options, callback, data) { + try { + let translations = require('../../locales/'+url+'.json'); + callback(translations, {status: '200'}); + } catch (e) { + callback(null, {status: '404'}); + } +} + +i18next + .use(XHR) + .init({ + debug: true, + lng: 'en', + backend: { + loadPath: '{{lng}}', + parse: (data) => data, + ajax: loadLocales + } + }, (err, t) => { + // ... + }); + const piwik = new ReactPiwik({ url: 'stats.data.gouv.fr', siteId: 39, @@ -39,36 +66,38 @@ export default class Layout extends Component { // track the initial pageview ReactPiwik.push(['trackPageView']) return ( - - <> -
- - - - - {/* Redirect to be removed in March (Google should have understood...)*/} - ( - - )} - /> - - - - - - - - - - - - - -