Giter VIP home page Giter VIP logo

Comments (4)

jamuhl avatar jamuhl commented on June 16, 2024

would be great if you write what is not working...i guess

router.get('/accounts',function(req, res){
  req.i18n.changeLanguage(req.query.lng);
});

does not have translations loaded?!? on server you should preload every language: https://www.i18next.com/configuration-options.html#languages-namespaces-resources

i18next.init({ preload: ['en', 'de', '...'] });

from i18next-browser-languagedetector.

balajimitosis avatar balajimitosis commented on June 16, 2024

Thanks for the response,
Added preload in init

i18next.use(i18nMiddleware.LanguageDetector)
.use(i18nFS)
.use(i18nSprintf)
.init({
debug: false,
fallbackLng: 'en',
pluralSeparator: '_',
keySeparator: '::',
nsSeparator: ':::',
detection: {
order: [ /'path', 'session',/ 'querystring', 'cookie', 'header'],
lookupQuerystring: 'lng',
lookupPath: 'lng',
lookupCookie: 'locaI18next',
cookieDomain: 'loca',
caches: ['cookie']
},
backend: {
loadPath: path.join(dist_directory, 'locales', '{{lng}}.json')
},
fallbackLng: 'en',
preload: ['en', 'fr', 'es']
});
But not successful.
Considering the route, am able to get language from the query string but i dont know how to apply that language, so that my EJS view changes( Though initially its able to detect the browser language and change ).
Currently am changing the language using jquery for translation in front end ( $('#signInEmail').html(i18next.t('E-mail')); ).But am forced to use timeout. thus for a fraction of sec, the browser language loads and then gets translated( which is really annoying ).

If you need any further information or any of my code.I will post.Thanks

from i18next-browser-languagedetector.

jamuhl avatar jamuhl commented on June 16, 2024

so your problem is not related to the rendering on the server...but on client...

you init i18next on client too...use the callback there to render i18next.init(options, () => { $('#signInEmail').html(i18next.t('E-mail')); })

or bind the initialized event: https://www.i18next.com/api.html#oninitialized

from i18next-browser-languagedetector.

balajimitosis avatar balajimitosis commented on June 16, 2024

Yeah, I think so, I will try.Thanks

from i18next-browser-languagedetector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.