-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example using web-dev-server to save missing translations
- Loading branch information
Showing
18 changed files
with
28,492 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SKIP_PREFLIGHT_CHECK=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
example using web-dev-server to save missing translations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const i18next = require('i18next'); | ||
const Backend = require('i18next-fs-backend'); | ||
const i18nextMiddleware = require('i18next-http-middleware'); | ||
const bodyParser = require('body-parser'); | ||
|
||
i18next | ||
.use(Backend) | ||
.use(i18nextMiddleware.LanguageDetector) | ||
.init({ | ||
backend: { | ||
loadPath: __dirname + '/public/locales/{{lng}}/{{ns}}.json', | ||
addPath: __dirname + '/public/locales/{{lng}}/{{ns}}.missing.json', | ||
}, | ||
fallbackLng: 'en', | ||
// debug: true, | ||
saveMissing: true, | ||
}); | ||
|
||
module.exports = { | ||
devServer: (configFunction) => (proxy, allowedHost) => { | ||
const config = configFunction(proxy, allowedHost); | ||
config.setupMiddlewares = (middlewares, devServer) => { | ||
if (!devServer) throw new Error('webpack-dev-server is not defined'); | ||
|
||
devServer.app.post( | ||
'/locales/:lng/:ns', | ||
bodyParser.json(), | ||
i18nextMiddleware.missingKeyHandler(i18next), | ||
); | ||
// addPath for client: http://localhost:3000/locales/{{lng}}/{{ns}} | ||
|
||
return middlewares; | ||
}; | ||
return config; | ||
}, | ||
}; |
Oops, something went wrong.