i18next/i18next-xhr-backend

Include user language with missing key in addPath

omonk opened this issue · 3 comments

omonk commented

Hopefully I'm reading this right...

As detailed in the README the parsePayload function gives us the ability to shape the form data submitted in the POST request, I was wondering if it is possible to include the language where said key is missing from?

parsePayload: function(namespace, key, fallbackValue, language) {
  return { key, namespace, language };
},

Am I thinking about it in the right way? Will the addPath function be fired if the key can't be found using the language detected?

Happy to expand on this PR if XHR Backend has access to current language that the key was not found in - #326

where it gets sent depends on the missing setting -> default would be fallback long: https://www.i18next.com/overview/configuration-options#missing-keys saveMissingTo

https://github.com/i18next/i18next-xhr-backend/blob/master/src/index.js#L73 -> sends to all languages defined for missing call

so language is passed in path not payload

omonk commented

Doh of course 🤦‍♂️ will pick it out of the url. Thanks for all your work on i18next the rapid reply!

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

If you liked my support / work - I would enjoy a coffee sponsored using the “💜Sponsor Button”.

There are many ways to help this project 🙏