From e75a97ee119b589b9d1aae1b88f9d0407bcdfdaf Mon Sep 17 00:00:00 2001 From: anuoluwaponiorimi <287817511+anuoluwaponiorimi@users.noreply.github.com> Date: Mon, 22 Jun 2026 19:56:59 +0100 Subject: [PATCH 1/2] Implement i18n support with next-intl (en/es) (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets up internationalization for the frontend using next-intl on the Pages Router, with English and Spanish locales. - next.config.js: enable Next.js built-in locale routing (locales: en, es; defaultLocale: en) — non-default locales are URL-prefixed (e.g. /es/explore) and exposed via useRouter().locale. - messages/en.json + messages/es.json: translation catalogs (Nav + LocaleSwitcher). - i18n/messages.ts: typed locale list, default, isLocale guard, and getMessages() resolver with a safe fallback to the default locale. - pages/_app.tsx: wrap the app in NextIntlClientProvider, selecting the catalog from the active router locale. - components/atoms/locale-switcher: accessible onChange(e.target.value as Locale)} + className="bg-transparent border border-gray-200 dark:border-gray-700 rounded-lg px-2 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 cursor-pointer focus:outline-none focus:ring-2 focus:ring-indigo-500" + > + {locales.map((loc) => ( + + ))} + + + ) +} diff --git a/components/organisms/navbar/index.tsx b/components/organisms/navbar/index.tsx index 44aa7d0..0167f0f 100644 --- a/components/organisms/navbar/index.tsx +++ b/components/organisms/navbar/index.tsx @@ -1,19 +1,22 @@ import { useState } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/router'; +import { useTranslations } from 'next-intl'; import { ThemeToggle } from '../../atoms/theme-toggle'; +import { LocaleSwitcher } from '../../atoms/locale-switcher'; const NAV_LINKS = [ - { label: 'Home', href: '/' }, - { label: 'Explore', href: '/explore' }, - { label: 'Leaderboard', href: '/leaderboard' }, - { label: 'Dashboard', href: '/dashboard' }, - { label: 'Escrow', href: '/escrow' }, -]; + { key: 'home', href: '/' }, + { key: 'explore', href: '/explore' }, + { key: 'leaderboard', href: '/leaderboard' }, + { key: 'dashboard', href: '/dashboard' }, + { key: 'escrow', href: '/escrow' }, +] as const; export function Navbar() { const [open, setOpen] = useState(false); const router = useRouter(); + const t = useTranslations('Nav'); const toggle = () => setOpen((v) => !v); const close = () => setOpen(false); @@ -27,7 +30,7 @@ export function Navbar() { {/* Desktop links */}