i18next / i18next-xhr-backend

[deprecated] can be replaced with i18next-http-backend
https://github.com/i18next/i18next-http-backend
MIT License
253 stars 75 forks source link

Include user language with missing key in addPath #346

Closed omonk closed 4 years ago

omonk commented 4 years ago

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 - https://github.com/i18next/i18next-xhr-backend/pull/326

jamuhl commented 4 years ago

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 4 years ago

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

jamuhl commented 4 years ago

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 “:purple_heart:Sponsor Button”.

There are many ways to help this project :pray: