Closed golubvladimir closed 4 years ago
My config
i18next .use(i18nextMiddleware.LanguageDetector) .use(FilesystemBackend) .init({ fallbackLng: ['en'], preload: ["en", "ru"], detection: { order: ['path'], lookupPath: 'lng', caches: false }, backend: { loadPath: path.join(__dirname, '../lang/json/{{lng}}.json'), jsonIndent: 2, } }); app.use( i18nextMiddleware.handle(i18next, { removeLngFromUrl: false }) ); app.get('/api/:lng/test-lang', (req, res) => { console.log(req.t('test')); });
GET http://localhost:3001/api/ru/test-lang GET http://localhost:3001/api/en/test-lang I get english translate.
Test Test
Why is i18next: languageChanged equal api ?
Fix config
detection: { order: ['path'], lookupPath: 'api/lng', lookupFromPathIndex: 1, caches: false },
My config
GET http://localhost:3001/api/ru/test-lang GET http://localhost:3001/api/en/test-lang I get english translate.
Why is i18next: languageChanged equal api ?