Add i18n support with Next.js App Router and Dictionaries

This commit is contained in:
AyrisAI
2026-05-14 12:56:43 +03:00
parent 89d74ce3fe
commit 4c9a07e3ef
24 changed files with 244 additions and 91 deletions

View File

@@ -4,31 +4,31 @@ import { useSession, signOut } from "next-auth/react";
import Link from "next/link";
import { usePathname } from "next/navigation";
const navItems = [
{
section: "GENEL",
items: [
{ href: "/dashboard", label: "Dashboard", icon: HomeIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
{ href: "/dashboard/mail", label: "Mail", icon: InboxIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
],
},
{
section: "YÖNETİM",
items: [
{ href: "/dashboard/domains", label: "Domainler", icon: GlobeIcon, roles: ["SUPER_ADMIN"] },
{ href: "/dashboard/users", label: "Kullanıcılar", icon: UsersIcon, roles: ["SUPER_ADMIN"] },
{ href: "/dashboard/mailboxes", label: "Mail Hesapları", icon: MailIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
],
},
];
export default function Sidebar() {
export default function Sidebar({ dict, lang }: { dict: any; lang: string }) {
const { data: session } = useSession();
const pathname = usePathname();
const role = session?.user?.role ?? "";
const name = session?.user?.name ?? "";
const email = session?.user?.email ?? "";
const navItems = [
{
section: "GENEL",
items: [
{ href: `/${lang}/dashboard`, label: "Dashboard", icon: HomeIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
{ href: `/${lang}/dashboard/mail`, label: dict.mailClient || "Mail", icon: InboxIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
],
},
{
section: "YÖNETİM",
items: [
{ href: `/${lang}/dashboard/domains`, label: "Domainler", icon: GlobeIcon, roles: ["SUPER_ADMIN"] },
{ href: `/${lang}/dashboard/users`, label: dict.users || "Kullanıcılar", icon: UsersIcon, roles: ["SUPER_ADMIN"] },
{ href: `/${lang}/dashboard/mailboxes`, label: dict.mailboxes || "Mail Hesapları", icon: MailIcon, roles: ["SUPER_ADMIN", "DOMAIN_ADMIN"] },
],
},
];
return (
<aside className="sidebar">
<div className="sidebar-logo">
@@ -80,11 +80,11 @@ export default function Sidebar() {
style={{ width: "100%", justifyContent: "center", fontSize: "12px" }}
onClick={async () => {
await signOut({ redirect: false });
window.location.href = "/login";
window.location.href = `/${lang}/login`;
}}
>
<LogOutIcon />
Çıkış Yap
{dict.logout || ıkış Yap"}
</button>
</div>
</aside>

View File

@@ -1,6 +1,6 @@
"use client";
import { useState, useRef, useCallback } from "react";
import type { MailMessage } from "@/app/dashboard/mail/page";
import type { MailMessage } from "@/app/[lang]/dashboard/mail/page";
import { formatBytes } from "@/lib/format";
interface AttachmentFile {

View File

@@ -1,5 +1,5 @@
"use client";
import type { MailFolder } from "@/app/dashboard/mail/page";
import type { MailFolder } from "@/app/[lang]/dashboard/mail/page";
const FOLDER_ICONS: Record<string, string> = {
"\\Inbox": "📥",

View File

@@ -1,5 +1,5 @@
"use client";
import type { MailEnvelope } from "@/app/dashboard/mail/page";
import type { MailEnvelope } from "@/app/[lang]/dashboard/mail/page";
function timeAgo(dateStr: string): string {
const now = new Date();

View File

@@ -1,5 +1,5 @@
"use client";
import type { MailMessage } from "@/app/dashboard/mail/page";
import type { MailMessage } from "@/app/[lang]/dashboard/mail/page";
import { formatBytes } from "@/lib/format";
function getFileIcon(contentType: string, filename: string): string {