Commit 7a937505 authored by Jan Mühlemann's avatar Jan Mühlemann Committed by Tim Neutkens

update with-react-i18next sample with latest dependencies (#3835)

parent 7e756ee5
...@@ -11,15 +11,15 @@ ...@@ -11,15 +11,15 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"express": "4.15.3", "express": "4.16.2",
"i18next": "8.4.2", "i18next": "10.4.1",
"i18next-browser-languagedetector": "2.0.0", "i18next-browser-languagedetector": "2.1.0",
"i18next-express-middleware": "1.0.5", "i18next-express-middleware": "1.0.10",
"i18next-node-fs-backend": "1.0.0", "i18next-node-fs-backend": "1.0.0",
"i18next-xhr-backend": "1.4.2", "i18next-xhr-backend": "1.5.1",
"next": "latest", "next": "5.0.0",
"react": "16.2.0", "react": "16.2.0",
"react-dom": "16.2.0", "react-dom": "16.2.0",
"react-i18next": "4.6.3" "react-i18next": "7.3.6"
} }
} }
...@@ -2,7 +2,6 @@ const express = require('express') ...@@ -2,7 +2,6 @@ const express = require('express')
const path = require('path') const path = require('path')
const next = require('next') const next = require('next')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production' const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev }) const app = next({ dev })
const handle = app.getRequestHandler() const handle = app.getRequestHandler()
...@@ -17,6 +16,7 @@ i18n ...@@ -17,6 +16,7 @@ i18n
.use(Backend) .use(Backend)
.use(i18nextMiddleware.LanguageDetector) .use(i18nextMiddleware.LanguageDetector)
.init({ .init({
fallbackLng: 'en',
preload: ['en', 'de'], // preload all langages preload: ['en', 'de'], // preload all langages
ns: ['common', 'home', 'page2'], // need to preload all the namespaces ns: ['common', 'home', 'page2'], // need to preload all the namespaces
backend: { backend: {
...@@ -41,9 +41,9 @@ i18n ...@@ -41,9 +41,9 @@ i18n
// use next.js // use next.js
server.get('*', (req, res) => handle(req, res)) server.get('*', (req, res) => handle(req, res))
server.listen(port, (err) => { server.listen(3000, (err) => {
if (err) throw err if (err) throw err
console.log(`> Ready on http://localhost:${port}`) console.log('> Ready on http://localhost:3000')
}) })
}) })
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment