i18next / i18next-http-middleware

i18next-http-middleware is a middleware to be used with Node.js web frameworks like express or Fastify and also for Deno.
MIT License
150 stars 28 forks source link

"Adding own detection functionality" missing a critical piece #55

Closed lukaromih closed 1 year ago

lukaromih commented 1 year ago

Documentation issue

Please expand the Adding own detection functionality with the note, similar to the one in the browser language detector docs.

I'm talking about Don't forget: You have to add the name of your detector (myDetectorsName in this case) to the order array in your options object. Without that, your detector won't be used. See the Detector Options section for more.

Motivation

Yesterday, I was setting up my Express.js i18n support and needed a custom language detector. I followed the documentation but couldn't get my own detector's lookup function to run. I was already thinking about having to inspect the source code to figure out what I'm missing, but luckily I found a closed issue, which eventually led me notice that the proper use of own language detector is described in the basic example. What I was missing was the fact, that you have to add it to the order array and the name to be used is the value of the name property you define in your own detector and not the name of the variable you pass it as to the addDetector method (duuh, obviously, yet I still used that one first). Today, when I'm implementing client integration, I noticed that the browser language detector documents that perfectly and the above mentioned snippet, if added to this library's docs, will probably help others avoid such trouble with their integrations...and possibly future me.