Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a default sub object of the custom AJAX payload #345

Open
jackblackCH opened this issue Mar 16, 2020 · 1 comment
Open

Return a default sub object of the custom AJAX payload #345

jackblackCH opened this issue Mar 16, 2020 · 1 comment

Comments

@jackblackCH
Copy link

jackblackCH commented Mar 16, 2020

My registered API via loadPath returns all translation keys in a nested "data" object.
i.e

{
  "data": {
      "key1": "foo",
      "key2: "bar"
   }
}

This forces me to use "data" like a namespace. i.e `t("data.mykey")". though it is not a namespace, it is just because I am not in control of the translation API.

Is there a way to always return a sub object of the JSON payload?

Lately I would like to use t("key1") instead of multiple t("data.key1") or t("data.key2").

@jamuhl
Copy link
Member

jamuhl commented Mar 17, 2020

Not looked deeper - but I guess you can use the parse option of the backend: https://github.com/i18next/i18next-xhr-backend#backend-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants