Example of i18next-express-middleware with i18next-node-remote-backend
See original GitHub issueI tried this:
var i18next = require('i18next');
var middleware = require('i18next-express-middleware');
var backend = require('i18next-node-remote-backend');
i18next
.use(middleware.LanguageDetector)
.use(backend)
.init({
debug: false,
detection: {
order: ['querystring', 'cookie']
},
backend: {
loadPath: 'http://example.com/translate?language={{lng}}',
crossDomain: true
}
});
and it does not seem to fetch the resource when I access the http://localhosst:3000/?lng=en
If I pass the lng
manually to the init options, it fetches the desired language passed to this variable, but I’d like to init the language bases on a variable like query param or cookie.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Any example on using remote backend · Issue #288 · i18next/next ...
It seems it must use node-fs-backend no matter what. If my resources are on remote ... In this case we're talking about i18next-express-middleware...
Read more >How do you configure i18next-express-middleware?
I am trying to get started using i18next with an Express server, but cannot get it working based on the examples in the...
Read more >Plugins and Utils - i18next documentation
i18nFormat plugin to use airbnb/polyglot.js format with i18next ... backend layer for i18next used in Node.js & Deno to load translations from the...
Read more >Node.js web frameworks like express or Fastify and also for ...
This is a middleware to be used with Node.js web frameworks like express or Fastify and also for Deno. It's based on the...
Read more >i18next-http-middleware vs react-i18next - compare differences and ...
i18next -http-middleware is a middleware to be used with Node.js web frameworks like express or Fastify and also for Deno. (by i18next).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for all the help, you are right!
you don’t have to init with a specific language on a webserver. think of it - every request comes from a different user with possible different language. If you set language globally you can cause errors by using the wrong language as a user two changes language during user ones request (async nature of node).
You basically should preload all the languages you support on server using the preload option on init (array of languages you want to load).