mirror of
https://github.com/KivotosRailway/website.git
synced 2026-11-03 19:07:56 +09:00
i18n 代码进入URL路由,优化重定向规则
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { useRouteLocale } from "@/components/layout/locale-context";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
import { applyLocale, getInitialLocale, getLocaleMessages, type Locale } from "@/lib/i18n";
|
||||
import { applyLocale, getInitialLocale, withLocale, getLocaleMessages, type Locale } from "@/lib/i18n";
|
||||
import { ThemeToggle } from "@/components/layout/theme-toggle";
|
||||
|
||||
const footerColumnHrefs = [
|
||||
@@ -18,7 +20,7 @@ function isIcpVisibleHost(hostname: string) {
|
||||
}
|
||||
|
||||
export function SiteFooter() {
|
||||
const [locale, setLocale] = useState<Locale>("zh-CN");
|
||||
const [locale, setLocale] = useState<Locale>(useRouteLocale());
|
||||
const [showIcp, setShowIcp] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -77,7 +79,7 @@ export function SiteFooter() {
|
||||
<h3>{group.title}</h3>
|
||||
<ul>
|
||||
{group.links.map((link, linkIndex) => (
|
||||
<li key={`column-${groupIndex}-link-${linkIndex}`}><a href={footerColumnHrefs[groupIndex][linkIndex]}>{link}</a></li>
|
||||
<li key={`column-${groupIndex}-link-${linkIndex}`}><a href={withLocale(footerColumnHrefs[groupIndex][linkIndex], locale)}>{link}</a></li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -100,7 +102,7 @@ export function SiteFooter() {
|
||||
<div className="site-footer-meta">
|
||||
<div className="site-footer-legal-row">
|
||||
{messages.footer.legal.map((item, itemIndex) => (
|
||||
<a key={`legal-${itemIndex}`} href={footerLegalHrefs[itemIndex]}>{item}</a>
|
||||
<a key={`legal-${itemIndex}`} href={withLocale(footerLegalHrefs[itemIndex], locale)}>{item}</a>
|
||||
))}
|
||||
</div>
|
||||
<p className="site-footer-description">{messages.footer.description}</p>
|
||||
|
||||
Reference in New Issue
Block a user