diff --git a/messages/en.json b/messages/en.json index 0987a94..b45f3f3 100644 --- a/messages/en.json +++ b/messages/en.json @@ -13,5 +13,51 @@ "signIn": "Sign in", "noAccount": "Don't have an account?", "createAccount": "Create account" + }, + "Sidebar": { + "title": "CRM Template for WhatsApp", + "dashboard": "Dashboard", + "inbox": "Inbox", + "notifications": "Notifications", + "contacts": "Contacts", + "pipelines": "Pipelines", + "broadcasts": "Broadcasts", + "automations": "Automations", + "flows": "Flows", + "aiAgents": "AI Agents", + "settings": "Settings", + "beta": "Beta", + "unreadConversations": "{count} unread {count, plural, =1 {conversation} other {conversations}}", + "unreadNotifications": "{count} unread {count, plural, =1 {notification} other {notifications}}", + "roleOwner": "Owner", + "roleAdmin": "Admin", + "roleAgent": "Agent", + "roleViewer": "Viewer", + "closeMenu": "Close menu", + "defaultUser": "User", + "defaultAvatar": "Avatar", + "menuProfile": "Profile", + "menuSettings": "Settings", + "menuSignOut": "Sign out" + }, + "Header": { + "dashboard": "Dashboard", + "inbox": "Inbox", + "notifications": "Notifications", + "contacts": "Contacts", + "pipelines": "Pipelines", + "broadcasts": "Broadcasts", + "automations": "Automations", + "settings": "Settings", + "openMenu": "Open menu", + "openAccountMenu": "Open account menu", + "defaultUser": "User", + "defaultAvatar": "Avatar", + "menuProfile": "Profile", + "menuSettings": "Settings", + "menuSignOut": "Sign out" + }, + "ModeToggle": { + "switchMode": "Switch to {mode} mode" } } diff --git a/src/components/layout/header.tsx b/src/components/layout/header.tsx index 45d615b..2746593 100644 --- a/src/components/layout/header.tsx +++ b/src/components/layout/header.tsx @@ -19,22 +19,22 @@ import { import { ModeToggle } from "@/components/layout/mode-toggle"; const pageTitles: Record = { - "/dashboard": "Dashboard", - "/inbox": "Inbox", - "/notifications": "Notifications", - "/contacts": "Contacts", - "/pipelines": "Pipelines", - "/broadcasts": "Broadcasts", - "/automations": "Automations", - "/settings": "Settings", + "/dashboard": "dashboard", + "/inbox": "inbox", + "/notifications": "notifications", + "/contacts": "contacts", + "/pipelines": "pipelines", + "/broadcasts": "broadcasts", + "/automations": "automations", + "/settings": "settings", }; -function getPageTitle(pathname: string): string { +function getPageTitleKey(pathname: string): string { if (pageTitles[pathname]) return pageTitles[pathname]; const match = Object.entries(pageTitles).find(([path]) => pathname.startsWith(path), ); - return match ? match[1] : "Dashboard"; + return match ? match[1] : "dashboard"; } interface HeaderProps { @@ -43,10 +43,13 @@ interface HeaderProps { onOpenSidebar?: () => void; } +import { useTranslations } from "next-intl"; + export function Header({ onOpenSidebar }: HeaderProps) { + const t = useTranslations("Header"); const pathname = usePathname(); const { profile, signOut } = useAuth(); - const title = getPageTitle(pathname); + const titleKey = getPageTitleKey(pathname); const initial = profile?.full_name?.charAt(0)?.toUpperCase() ?? @@ -60,13 +63,13 @@ export function Header({ onOpenSidebar }: HeaderProps) {

- {title} + {t(titleKey as any)}

@@ -76,13 +79,13 @@ export function Header({ onOpenSidebar }: HeaderProps) { {profile?.avatar_url ? ( ) : null} @@ -90,7 +93,7 @@ export function Header({ onOpenSidebar }: HeaderProps) { - {profile?.full_name ?? "User"} + {profile?.full_name ?? t("defaultUser")}

- {profile?.full_name ?? "User"} + {profile?.full_name ?? t("defaultUser")}

{profile?.email ?? ""} @@ -116,7 +119,7 @@ export function Header({ onOpenSidebar }: HeaderProps) { } > - Profile + {t("menuProfile")} - Settings + {t("menuSettings")} - Sign out + {t("menuSignOut")} diff --git a/src/components/layout/mode-toggle.tsx b/src/components/layout/mode-toggle.tsx index 273dc10..acf7bfc 100644 --- a/src/components/layout/mode-toggle.tsx +++ b/src/components/layout/mode-toggle.tsx @@ -5,6 +5,8 @@ import { Moon, Sun } from "lucide-react"; import { useTheme } from "@/hooks/use-theme"; import { cn } from "@/lib/utils"; +import { useTranslations } from "next-intl"; + /** * Light/dark mode toggle — a single icon button that flips the app * between the two modes. Sun shows in light mode (click → go dark), @@ -14,14 +16,17 @@ import { cn } from "@/lib/utils"; * 40×40 hit target to match the header's other touch controls. */ export function ModeToggle({ className }: { className?: string }) { + const t = useTranslations("ModeToggle"); const { mode, toggleMode } = useTheme(); const goingTo = mode === "dark" ? "light" : "dark"; + const switchLabel = t("switchMode", { mode: goingTo }); + return (

- CRM Template for WhatsApp + {t("title")}