Correct way to use translations in SSR #1643
-
Hi, I have a use case where I need (or at least want) to translate some content already in the static rendering phase. As per the docs, I'm loading the translations successfully with Is there any other or better way to consume these translations than referencing the object itself, something looking more like the const i18nProps = await serverSideTranslations(locale, [
'my_namespace'
]);
const someThingWithTranslation = {
value: 123,
label: i18nProps._nextI18Next.initialI18nStore[locale].my_namespace.some_key
}
return {
props: {
someThingWithTranslation
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Are you able to consume the global i18n instance? import { i18n } from 'next-i18next'
i18n.t('my-namespace:my-key') |
Beta Was this translation helpful? Give feedback.
Are you able to consume the global i18n instance?