For my current project, I am utilizing both i18next
and react-i18next
. One useful feature of using the useTranslation
hook from react-i18next
is the "keyPrefix" option, which helps in reducing code duplication. However, there are instances where I need to access i18next functionalities outside of components. Is there any abstraction similar to useTranslation
that would allow me to use parameters like ns
or keyPrefix
without having to repeat them every time I call the t
function?
I have searched through i18next's documentation for such a solution, but I have yet to come across anything applicable.
In an attempt to address this issue myself using the adapter pattern, I encountered challenges with TypeScript support as I could not obtain the type of the key for the t
function.