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

Customize payload sended by `addPath` #325

Open Pitbi opened 4 years ago

Pitbi commented 4 years ago

Hey,

Would it be possible to add the possibility of having control over the payload sent on POST to addPath?

It would be useful to be able to choose the payload key.

For example: {key: 'my_i18n_key'} instead of {my_i18n_key: 'my_i18n_key'}

Thank you for reading me.

jamuhl commented 4 years ago

Why would you manipulate the key? That would be unresolvable from i18next.

Pitbi commented 4 years ago

I would like to POST the key in a tool. The API of the tool requests a payload like {key: 'my_i18n_key'}.

jamuhl commented 4 years ago

That tool is not our https://locize.com I guess...

The only option currently I see to do so is overriding the ajax: https://github.com/i18next/i18next-xhr-backend#backend-options

Pitbi commented 4 years ago

No, you right. It's an other.

Ok, that's what I did. But it's a shame, I create a custom request only to change the payload sent. So I guess you have no interest in adding this option?

Thank you for your follow-up.

jamuhl commented 4 years ago

If you like you can add something like done on load: https://github.com/i18next/i18next-xhr-backend/blob/master/src/index.js#L56

having a default option for the create call parseBeforeAdd or something like that?

Pitbi commented 4 years ago

Ok, I can think about that.

I'll be back soon :)