refine
refine copied to clipboard
[DOC] i18n Provider Section -> i18n trying to fetch translation.json & updating the installation
Documentation issue
Currently, i18n is trying to fetch translation.json file in the relative language directory before falling back to the defaultNs.
Can be seen below
This is the code thats responsible for it https://github.com/refinedev/refine/blob/2d48c4e368da1c06f28f7eca36c85b5900dea66a/examples/i18n-react/src/i18n.ts#L6-L17
Another problem that I noticed is that in the docs we only installed 2 packages but missed out on installing i18next-http-backend and i18next-browser-languagedetector packages which are then later immediately imported in the next section where we creating the i18n instance:
Describe the thing to improve
- For the first issue, Just add the ns property and set it to be an array of common namespace that is being used in the defaultNs
- For the second one, we can just import all the required packages, instead of installing them separately since they are being imported immediately in the next session when creating the i18n instance.
Describe the solution (optional)
1. Just by setting ns option to be an array of the namespace that is used in the defaultNs fixes it.
This is because by default ns is set to translation and it still tries to fetch it before it uses the defaultNs
i18n.use(Backend)
.use(detector)
.use(initReactI18next)
.init({
supportedLngs: ["en", "de"],
backend: {
loadPath: "/locales/{{lng}}/{{ns}}.json",
},
+ ns: ["common"],
defaultNS: "common",
fallbackLng: ["en", "de"],
});
2. For the second issue we can just install the two packages togather:
- npm install react-i18next i18next
+ npm install react-i18next i18next i18next-http-backend i18next-browser-languagedetector
Hey @shahan007, We are sorry for this issue. If you want to support us, can you open a PR for this issue? 🙏🏼
Hi ! sure I will do that
Hello @shahan007 We've fixed this issue on refine.new and our cli generated projects, only thing left is documentation. Are you still interested in working on this one? If so, let us know so we can close this issue.
I wasnt feeling well for couple of days 😅 Yup, I will work on it. @BatuhanW I have created a pull request for this https://github.com/refinedev/refine/pull/4597
Thanks for the PR @shahan007 and congrats on your first contribution! Hope it'll one first of many!