Skip to content

Commit

Permalink
feat: dashboard multi lang
Browse files Browse the repository at this point in the history
  • Loading branch information
张欢 committed Sep 18, 2024
1 parent 25fda72 commit 5027659
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/app/[locale]/(docs)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function DocsLayout({ children, params: {locale} }: DocsLayoutPro
return (
<div className="flex flex-col">
<NavMobile marketingConfig={marketingConfig} translations={translations} />
<NavBar marketingConfig={marketingConfig} />
<NavBar marketingConfig={marketingConfig} translations={translations} />
<MaxWidthWrapper className="min-h-screen" large>
{children}
</MaxWidthWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(marketing)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function MarketingLayout({
return (
<div className="flex min-h-screen flex-col">
<NavMobile marketingConfig={marketingConfig} translations={translations} />
<NavBar scroll={true} marketingConfig={marketingConfig} />
<NavBar scroll={true} marketingConfig={marketingConfig} translations={translations} />
<main className="flex-1">{children}</main>
<SiteFooter />
</div>
Expand Down
36 changes: 23 additions & 13 deletions src/components/layout/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
"use client";

import Link from "@/components/link/link";
import { useContext } from "react";
import { useSelectedLayoutSegment } from "next/navigation";
import { MarketingConfig } from "@/types";
import { useSession } from "next-auth/react";
import { useLocale } from "next-intl";
import { useSelectedLayoutSegment } from "next/navigation";
import { useContext } from "react";

import { docsConfig } from "@/config/docs";
import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
import { useScroll } from "@/hooks/use-scroll";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import Link from "@/components/link/link";
import LocaleSwitcher from "@/components/locale/locale-switcher";
import { ModalContext } from "@/components/modals/providers";
import { Icons } from "@/components/shared/icons";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { docsConfig } from "@/config/docs";
import { siteConfig } from "@/config/site";
import { useScroll } from "@/hooks/use-scroll";
import { cn } from "@/lib/utils";
import { MarketingConfig } from "@/types";

interface NavBarProps {
scroll?: boolean;
marketingConfig: MarketingConfig;
translations: {
adminPanel: string;
dashboard: string;
login: string;
signUp: string;
};
}

export function NavBar({ scroll = false, marketingConfig }: NavBarProps) {
export function NavBar({
scroll = false,
marketingConfig,
translations,
}: NavBarProps) {
const locale = useLocale();

const scrolled = useScroll(50);
Expand Down Expand Up @@ -115,7 +125,7 @@ export function NavBar({ scroll = false, marketingConfig }: NavBarProps) {
className="gap-2 bg-primary px-5 text-primary-foreground hover:bg-primary/90"
size="sm"
>
<span>Dashboard</span>
<span> {translations.dashboard} </span>
</Button>
</Link>
) : status === "unauthenticated" ? (
Expand All @@ -124,7 +134,7 @@ export function NavBar({ scroll = false, marketingConfig }: NavBarProps) {
size="sm"
onClick={() => setShowSignInModal(true)}
>
<span>Sign In</span>
<span> {translations.login} </span>
<Icons.arrowRight className="size-4" />
</Button>
) : (
Expand Down
8 changes: 4 additions & 4 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"sidebar": {
"menu": "菜单",
"adminPanel": "管理员面板",
"dashboard": "仪表盘",
"dashboard": "控制面板",
"billing": "账单",
"charts": "图表",
"chatBot": "聊天机器人",
Expand All @@ -84,7 +84,7 @@
"support": "支持"
},
"main": {
"heading": "仪表盘",
"heading": "控制面板",
"currentRole": "当前角色:{role} — 在设置中更改您的角色。",
"noContentTitle": "尚未创建内容",
"noContentDescription": "您还没有任何内容。开始创建内容吧。",
Expand Down Expand Up @@ -264,7 +264,7 @@
"documentation": "文档"
},
"siteName": "FFlow Next",
"dashboard": "仪表盘",
"dashboard": "控制面板",
"login": "登录",
"signUp": "注册",
"admin": "管理员"
Expand Down Expand Up @@ -303,7 +303,7 @@
},
"UserAccountNav": {
"admin": "管理员",
"dashboard": "仪表盘",
"dashboard": "控制面板",
"settings": "设置",
"logOut": "退出登录"
},
Expand Down

0 comments on commit 5027659

Please sign in to comment.