fix(i18n): add DefaultIntlProvider for non-locale routes (#657)

@coderabbitai ignore

## Summary
- Hotfix for #656 — shared components using `useTranslations()` crashed
on non-locale routes (`/app`, `/admin`) because they had no
`NextIntlClientProvider`
- Adds `DefaultIntlProvider` (client component) to root layout that
provides English translations as fallback
- The `[locale]/layout.tsx` overrides this for locale-prefixed routes

## Test plan
- [x] All 707 frontend tests pass
- [x] Static build generates all 45 pages
- [ ] Verify `/app` dashboard loads without errors
- [ ] Verify `/admin` pages load without errors
- [ ] Verify `/en/app` still works with locale-specific provider

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrew Beveridge ☄️andClaude Opus 4.6 authored and GitHub committed 2026-04-03 22:16:29 -04:00
1 parent 8c1dfe5460
commit cba0e00bcc
2 files changed
+30 -11

No files matched your search

+14 -11
View File
@@ -3,6 +3,7 @@ import type { Metadata } from "next"
import localFont from "next/font/local"
import { ThemeProvider } from "@/components/theme-provider"
import { TenantProvider } from "@/components/tenant-provider"
import { DefaultIntlProvider } from "@/components/default-intl-provider"
import { ImpersonationBannerWrapper } from "@/components/impersonation-banner-wrapper"
import { ServiceWorkerRegistration } from "@/components/service-worker-registration"
import { GoogleAnalytics } from "@/components/google-analytics"
@@ -40,17 +41,19 @@ export default function RootLayout({
<body className={`font-sans antialiased ${titleCardFont.variable}`} style={{ background: 'var(--bg)', color: 'var(--text)' }}>
<GoogleAnalytics />
<ServiceWorkerRegistration />
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
<TenantProvider>
<ImpersonationBannerWrapper />
{children}
</TenantProvider>
</ThemeProvider>
<DefaultIntlProvider>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
<TenantProvider>
<ImpersonationBannerWrapper />
{children}
</TenantProvider>
</ThemeProvider>
</DefaultIntlProvider>
</body>
</html>
)
@@ -0,0 +1,16 @@
"use client"
import { NextIntlClientProvider } from "next-intl"
import enMessages from "@/messages/en.json"
/**
* Provides default English translations for routes outside [locale] (e.g., /admin, /app).
* The [locale]/layout.tsx provides locale-specific translations that override this.
*/
export function DefaultIntlProvider({ children }: { children: React.ReactNode }) {
return (
<NextIntlClientProvider locale="en" messages={enMessages}>
{children}
</NextIntlClientProvider>
)
}