Skip to content

Commit

Permalink
feat: footer multi lang
Browse files Browse the repository at this point in the history
  • Loading branch information
张欢 committed Sep 18, 2024
1 parent d6f561e commit 25fda72
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/layout/site-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react";
import Link from "@/components/link/link";
import { useTranslations } from "next-intl";

import { footerLinks, siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
Expand All @@ -9,13 +10,15 @@ import { NewsletterForm } from "../forms/newsletter-form";
import { Icons } from "../shared/icons";

export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
const t = useTranslations("Footer");

return (
<footer className={cn("border-t", className)}>
<div className="container grid max-w-6xl grid-cols-2 gap-6 py-14 md:grid-cols-5">
{footerLinks.map((section) => (
<div key={section.title}>
<span className="text-sm font-medium text-foreground">
{section.title}
{t(`sections.${section.title}.title`)}
</span>
<ul className="mt-4 list-inside space-y-3">
{section.items?.map((link) => (
Expand All @@ -24,7 +27,7 @@ export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
href={link.href}
className="text-sm text-muted-foreground hover:text-primary"
>
{link.title}
{t(`sections.${section.title}.items.${link.title}`)}
</Link>
</li>
))}
Expand All @@ -38,11 +41,8 @@ export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {

<div className="border-t py-4">
<div className="container flex max-w-6xl items-center justify-between">
{/* <span className="text-muted-foreground text-sm">
Copyright &copy; 2024. All rights reserved.
</span> */}
<p className="text-left text-sm text-muted-foreground">
Built by{" "}
{t("builtBy")}{" "}
<Link
href={siteConfig.links.twitter}
target="_blank"
Expand All @@ -51,7 +51,7 @@ export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
>
NoOne
</Link>
. Hosted on{" "}
. {t("hostedOn")}{" "}
<Link
href="https://www.cloudflare.com"
target="_blank"
Expand All @@ -60,7 +60,7 @@ export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
>
Cloudflare
</Link>
. Illustrations by{" "}
. {t("illustrationsBy")}{" "}
<Link
href="https://popsy.co"
target="_blank"
Expand Down
34 changes: 34 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,39 @@
"dashboard": "Dashboard",
"settings": "Settings",
"logOut": "Log out"
},
"Footer": {
"sections": {
"Company": {
"title": "Company",
"items": {
"About": "About",
"Enterprise": "Enterprise",
"Terms": "Terms",
"Privacy": "Privacy"
}
},
"Product": {
"title": "Product",
"items": {
"Security": "Security",
"Customization": "Customization",
"Customers": "Customers",
"Changelog": "Changelog"
}
},
"Docs": {
"title": "Docs",
"items": {
"Introduction": "Introduction",
"Installation": "Installation",
"Components": "Components",
"Code Blocks": "Code Blocks"
}
}
},
"builtBy": "Built by",
"hostedOn": "Hosted on",
"illustrationsBy": "Illustrations by"
}
}
34 changes: 34 additions & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,39 @@
"dashboard": "仪表盘",
"settings": "设置",
"logOut": "退出登录"
},
"Footer": {
"sections": {
"Company": {
"title": "公司",
"items": {
"About": "关于我们",
"Enterprise": "企业版",
"Terms": "服务条款",
"Privacy": "隐私政策"
}
},
"Product": {
"title": "产品",
"items": {
"Security": "安全性",
"Customization": "定制化",
"Customers": "客户",
"Changelog": "更新日志"
}
},
"Docs": {
"title": "文档",
"items": {
"Introduction": "介绍",
"Installation": "安装",
"Components": "组件",
"Code Blocks": "代码块"
}
}
},
"builtBy": "开发者",
"hostedOn": "托管于",
"illustrationsBy": "插图来自"
}
}

0 comments on commit 25fda72

Please sign in to comment.