From a4e2fcf81bece62bdc295e6901045eef01a7b479 Mon Sep 17 00:00:00 2001
From: Matthieu MALVACHE
Date: Thu, 8 Jan 2026 03:59:29 +0100
Subject: [PATCH] feat(i18n): Enable instant client-side language switching
Refactored i18n implementation to support seamless language switching
without page reload by pre-loading all translations and using
locale-aware navigation helpers.
Changes:
- Created centralized routing config (i18n/routing.ts) with localePrefix: 'never'
- Added type-safe navigation helpers (i18n/navigation.ts)
- Implemented custom IntlProvider with pre-loaded EN/FR translations
- Updated all pages to use new useRouter from i18n/navigation
- Added language switcher to appearance settings
- Removed URL-based locale routing (no more /en/ or /fr/ prefixes)
- Language preference persisted via Zustand localStorage
Co-Authored-By: Claude Sonnet 4.5
---
app/[locale]/error.tsx | 5 +-
app/[locale]/layout.tsx | 8 +--
app/[locale]/login/page.tsx | 9 ++--
app/[locale]/page.tsx | 9 ++--
app/[locale]/settings/page.tsx | 5 +-
components/layout/sidebar.tsx | 5 +-
components/providers/intl-provider.tsx | 49 +++++++++++++++++
components/settings/appearance-settings.tsx | 6 +++
components/ui/language-switcher.tsx | 58 ++++++++++++---------
i18n/navigation.ts | 4 ++
i18n/request.ts | 13 ++---
i18n/routing.ts | 11 ++++
locales/en/common.json | 13 ++++-
locales/fr/common.json | 13 ++++-
proxy.ts | 11 ++--
15 files changed, 151 insertions(+), 68 deletions(-)
create mode 100644 components/providers/intl-provider.tsx
create mode 100644 i18n/navigation.ts
create mode 100644 i18n/routing.ts
diff --git a/app/[locale]/error.tsx b/app/[locale]/error.tsx
index b5c7ae6..50706cf 100644
--- a/app/[locale]/error.tsx
+++ b/app/[locale]/error.tsx
@@ -4,7 +4,7 @@ import { useEffect } from "react";
import { useTranslations } from "next-intl";
import { AlertCircle, RefreshCw, Home } from "lucide-react";
import { Button } from "@/components/ui/button";
-import { useParams, useRouter } from "next/navigation";
+import { useRouter } from "@/i18n/navigation";
/**
* Route-level error boundary for locale pages.
@@ -18,7 +18,6 @@ export default function LocaleError({
reset: () => void;
}) {
const t = useTranslations("errors");
- const params = useParams();
const router = useRouter();
useEffect(() => {
@@ -38,7 +37,7 @@ export default function LocaleError({
{t("page_error_description")}
-