Coder Social home page Coder Social logo

Comments (4)

totymedli avatar totymedli commented on August 14, 2024 3

Solution

I found out you also have to add your custom detector's name into the detection.order array. This is somewhy not mentioned in the official readme. Without this, the detector will be never used.

Under the detector options section, there is an example object that can be set as the detection property in the object you pass to i18next.init(). You should add the name of your detector (customDetector) to the property called order in that options object.

i18next
  .use(LngDetector)
  .init({
    detection: {
      // order and from where user language should be detected
      order: ['customDetector', 'querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag']
    }
  });

from i18next-browser-languagedetector.

totymedli avatar totymedli commented on August 14, 2024 2

Now this information is included in the readme.

from i18next-browser-languagedetector.

jamuhl avatar jamuhl commented on August 14, 2024

you need to implement the detection function too: https://www.i18next.com/misc/creating-own-plugins.html#languagedetector

simpler would be using default detector and whitelist in options: https://www.i18next.com/configuration-options.html#languages-namespaces-resources

-> whitelist
-> nonExplicitWhitelist

from i18next-browser-languagedetector.

lopis avatar lopis commented on August 14, 2024

Thanks, that's what I was looking for. Maybe the readme should have a more complete example of a custom detector? Mind if I suggest one later in pull request?

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.