Closed viclafouch closed 5 months ago
Are you setting the namespace in useTranslation
hook from react-i18next?
Yep, I'm doing this const { t } = useTranslation(['checkup', 'common'])
Doesn't change anything :/
export const handle = {
i18n: ['checkUp']
}
const CheckUpRoute = () => {
// root.tsx has the `common` in the handle
const { t } = useTranslation(['checkup', 'common'])
...
}
Ooo I find, it was checkUp
and no checkup
.
BUT, now, it's working, and at the same time, I added translations to the meta (title, description, etc..). But it's kind of slow when I change page.
export const loader = async ({ request }: LoaderFunctionArgs) => {
const t = await i18nextServer.getFixedT(request, 'followUp')
const title = t('followUp:afterCheckUp')
return json({ title })
}
In my network tab, it take 1 second to load the page just because of this Promise, it's a lot. Do you have any tips to accelerate this ? Like caching ? Defer ?
If you're fetching the translations from a service I would cache that If your translations are deployed along your app I would load them immediately since there's no benefit of on-demand load server-side
OK perfect thanks !
Describe the bug
Following this discussion : https://github.com/sergiodxa/remix-i18next/discussions/171
Looks like it's an issue :/
What's the solution ?
Your Example Website or App
/
Steps to Reproduce the Bug or Issue
Example :
export const handle = { i18n: ['checkUp'] }
export const handle = { i18n: ['home'] }
export const handle = { i18n: ['followUp'] }
You hardreload on Route 1, you have your correct namespaces / translations. But If I go on the Route 2, then
getInitialNamespaces
function fromremix-i18next/client
is not executed again.. So we all of the keys are not translated..Expected behavior
If you go on Route 2 from Route 1, your namespaces must be loaded first.
Screenshots or Videos
No screenshots
Platform
Additional context
No response