My client-side analytics solution requires me to run some code after all of the translations have been loaded by next-i18next, but I can't figure out how to do this.
Specifically, I need to run the code after my document.title
has been updated with the new translated string.
I've tried adding event handlers, but it doesn't work.
import { i18n } from 'next-i18next'
// these never fire
i18n?.on("initialized", () => console.log("initialized"))
i18n?.on("loaded", () => console.log("loaded"))
// this doesn't work either
const { i18n } = useTranslation()
i18n?.on("initialized", () => console.log("initialized"))
i18n?.on("loaded", () => console.log("loaded"))