Git Product home page Git Product logo

Comments (5)

jamuhl avatar jamuhl commented on June 1, 2024

Need more details...i18next.languages is empty there...can't be after initializing at least not if either you set a lng on init or use the browser-languagedetector....

from i18next-fluent.

oasalonen avatar oasalonen commented on June 1, 2024

I'm able to reproduce this issue server-side where I'm using i18nextMiddleware.LanguageDetector in a node.js express app. My i18next init looks like this:

    i18next
        .use(i18nextMiddleware.LanguageDetector)
        .use(FilesystemBackend)
        .use(Fluent)
        .init({
            debug: true,
            fallbackLng: 'en',
            preload: ['en', 'de'],
            ns: ['translation', 'my.namespace'],
            detection: {
                order: ['cookie', 'querystring', 'header'],
                lookupCookie: 'lang'
            },
            backend: {
                loadPath: path.join(__dirname, '..', '..', 'client', 'build', 'locales/{{lng}}/{{ns}}.ftl'),
                parse: function(data) {
                    return ftl2js(data);
                }
            }
        });

It works if I set the lng option, but then that bypasses the language detection.

from i18next-fluent.

jamuhl avatar jamuhl commented on June 1, 2024

On serverside that can't really work...not this way...language detection happens during request - not on init -> there is also not the main instance used but a cloned instance on request!!!

So https://github.com/i18next/i18next-fluent/blob/master/src/index.js#L66 has to be done based on languages in preload.

A PR would be very welcome...

from i18next-fluent.

genert avatar genert commented on June 1, 2024

@oasalonen If memory serves correctly I think that was the issue.

BTW, been using this library since this issue was created so kudos @jamuhl for creating this library!

from i18next-fluent.

jamuhl avatar jamuhl commented on June 1, 2024

thank you both for making this module better 👍

from i18next-fluent.

Related Issues (4)

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.