I am running 1.11.6 and have a description component setup like this:
description: ({ value }) => (
<CharacterCounterDescription
value={value}
min={min}
max={max}
recommendedMin={recommendedMin}
recommendedMax={recommendedMax}
/>
),
Within
CharacterCounterDescription
, I am calling
useTranslation
from
react-i18next
const { i18n } = useTranslation();
console.log(i18n.language);
However, the console.log always returns
undefined
.
My payload config has the following in it
i18n: {
fallbackLng: 'en',
debug: false,
resources: {
en: {
custom: {
...en,
},
},
},
},
I've seen a warning in the console about needing to call
initReactI18next
-- is this not called by Payload?
Here's the error
react-i18next:: You will need to pass in an i18next instance by using initReactI18next
FieldDescription@http://localhost:8080/admin/main.js:99101:48
I don't think I'm doing anything different than the docs describe here
https://payloadcms.com/docs/admin/components#getting-the-current-language
Perhaps I'm missing something though
My version of react-i18next was 13.0.1, once I changed it to be the same as what is in Payload's package.json, it works.
Would it make sense for Payload to define it as a peerDependency?
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.