File size: 629 Bytes
88c4c60 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | "use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
import { initRuntimeI18n, reloadTranslations } from "./runtime";
export function RuntimeI18nProvider({ children }) {
const pathname = usePathname();
useEffect(() => {
initRuntimeI18n();
}, []);
// Re-process DOM when route changes
useEffect(() => {
if (pathname) {
// Double RAF to ensure React has committed changes to DOM
requestAnimationFrame(() => {
requestAnimationFrame(() => {
reloadTranslations();
});
});
}
}, [pathname]);
return <>{children}</>;
}
|