diff --git a/package.json b/package.json index cf957c0e..e2d4ef19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-translate", - "version": "1.5.0-canary.3", + "version": "1.5.0-canary.4", "description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.", "license": "MIT", "keywords": [ diff --git a/src/I18nProvider.tsx b/src/I18nProvider.tsx index 02df0f99..13c95e1e 100644 --- a/src/I18nProvider.tsx +++ b/src/I18nProvider.tsx @@ -17,6 +17,7 @@ export default function I18nProvider({ const { locale, defaultLocale } = useRouter() || {} const internal = useContext(InternalContext) const allNamespaces: Record = { + ...initialBrowserNamespaces(), ...internal.ns, ...namespaces, } @@ -35,3 +36,8 @@ export default function I18nProvider({ ) } + +function initialBrowserNamespaces() { + if (typeof window === 'undefined') return {} + return window.__NEXT_DATA__?.props?.__namespaces || {} +}