Closed andycaramba closed 7 years ago
rather sure you can't yet use import statement for i18next-express-middleware on node.js it would use the commonjs build -> import should be const middleware = require('i18next-express-middleware');
or importing: import { default as middleware } from 'i18next-express-middleware';
import { default as middleware } from 'i18next-express-middleware';
throws the same error but const middleware = require('i18next-express-middleware');
works fine
Thank you.
Will need to update this module at some point to better support the import statements.
it works for me:
import i18nMiddleware, { LanguageDetector } from 'i18next-express-middleware';
i18nextMiddleware has the following methods:
i18nextMiddleware {
handle: [Function: handle],
getResourcesHandler: [Function: getResourcesHandler],
missingKeyHandler: [Function: missingKeyHandler],
addRoute: [Function: addRoute]
}
As said @henryhuang, the import statement shoud beimport i18nMiddleware, { LanguageDetector } from 'i18next-express-middleware';
import * as i18nextMiddleware from 'i18next-express-middleware';
console.log(i18nextMiddleware);
// outputs:
{ LanguageDetector: { [Function: LanguageDetector] type: 'languageDetector' },
handle: [Function: handle],
getResourcesHandler: [Function: getResourcesHandler],
missingKeyHandler: [Function: missingKeyHandler],
addRoute: [Function: addRoute],
default:
{ handle: [Function: handle],
getResourcesHandler: [Function: getResourcesHandler],
missingKeyHandler: [Function: missingKeyHandler],
addRoute: [Function: addRoute] } }
This should be reopened and there should be made a fix to include also LanguageDetector
(like everything else) in the default export. I'm sure there will be much more people wasting their time on this.
Hi. I've got this error with i18next-express-middleware
I use webpack and babel-node to start my app (
babel-node --harmony src/server
)src/server/i18n.js
contentsrc/server/services/authentication/index.js
content (I use feathersjs as server framework)my
webpack.server.config.js
content