mirror of
https://github.com/dyzulk/trustlab-docs.git
synced 2026-01-26 13:32:08 +07:00
fix(i18n): internalize locale logic in LandingPage to resolve content mismatch
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { ArrowRight, Shield, Globe, Lock, Server, Zap, ChevronRight } from "lucide-react";
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
interface LandingPageProps {
|
||||
locale?: 'en' | 'id';
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
const translations = {
|
||||
@@ -46,9 +47,12 @@ const translations = {
|
||||
}
|
||||
};
|
||||
|
||||
export function LandingPage({ locale = 'en' }: LandingPageProps) {
|
||||
console.log('LandingPage Locale:', locale);
|
||||
const t = translations[locale] || translations.en;
|
||||
export function LandingPage({ locale: propLocale }: LandingPageProps) {
|
||||
const { locale: routerLocale, defaultLocale } = useRouter();
|
||||
const currentLocale = (propLocale || routerLocale || defaultLocale || 'en') as 'en' | 'id';
|
||||
|
||||
console.log('LandingPage Final Locale:', currentLocale);
|
||||
const t = translations[currentLocale] || translations.en;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-16 py-8">
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
const PUBLIC_FILE = /\.(.*)$/
|
||||
|
||||
export function middleware(req: NextRequest) {
|
||||
if (
|
||||
req.nextUrl.pathname.startsWith('/_next') ||
|
||||
req.nextUrl.pathname.includes('/api/') ||
|
||||
PUBLIC_FILE.test(req.nextUrl.pathname)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if (req.nextUrl.locale === 'default') {
|
||||
const locale = req.cookies.get('NEXT_LOCALE')?.value || 'en'
|
||||
return NextResponse.redirect(
|
||||
new URL(`/${locale}${req.nextUrl.pathname}${req.nextUrl.search}`, req.url)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { LandingPage } from '../components/LandingPage'
|
||||
|
||||
export const Index = () => {
|
||||
const { locale } = useRouter()
|
||||
return <LandingPage locale={locale} />
|
||||
}
|
||||
|
||||
<Index />
|
||||
|
||||
# DEBUG_ID_FILE_RENDERED
|
||||
Reference in New Issue
Block a user