i18n 代码进入URL路由,优化重定向规则

This commit is contained in:
2026-09-16 20:03:41 +08:00
parent d4bd36f5f8
commit f63f70d08b
42 changed files with 361 additions and 141 deletions
+11
View File
@@ -0,0 +1,11 @@
"use client";
import { createContext, useContext } from "react";
import type { Locale } from "@/lib/i18n";
export const LocaleContext = createContext<Locale>("zh-Hans");
export function useRouteLocale() { return useContext(LocaleContext); }
export function LocaleProvider({ locale, children }: { locale: Locale; children: React.ReactNode }) {
return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>;
}