I use i18next in my node app to internazionalize it.
My settings :
i18next.init({
load: 'current',
saveMissing: true,
sendMissingTo : 'all',
ignoreRoutes: ['img/','images/', 'public/', 'css/', 'js/'],
debug: true,
supportedLngs: ['en-US', 'fr-FR'],
fallbackLng: 'fr-FR'
});
On the client side I have two links for changing the language :
<a href="/setLanguage/en-US">English</a>
<a href="/setLanguage/fr-FR">Francais</a>
and on the server side I catch the two possibilities (I change the language ad redirect to the Welcome page):
app.get('/setLanguage/:lng', function(req, res){
console.log('Change language : ' + req.params.lng);
i18next.setLng(req.params.lng, function(){
res.redirect('/');
});
});
The problem is point 2 :
- that change correctly the selected language
- redirecting to the '/' reload the language to default value.
How to not reload it ?