| 1 | "use client"; |
| 2 | |
| 3 | import type { ReactNode } from "react"; |
| 4 | import { usePathname } from "next/navigation"; |
| 5 | |
| 6 | export function DocsLanguageRegion({ |
| 7 | locale, |
| 8 | englishTopics, |
| 9 | children, |
| 10 | }: { |
| 11 | locale: string; |
| 12 | englishTopics: string[]; |
| 13 | children: ReactNode; |
| 14 | }) { |
| 15 | const pathname = usePathname() ?? ""; |
| 16 | const rest = pathname.split("/").filter(Boolean); |
| 17 | const inDocs = rest[0] === locale && rest[1] === "docs"; |
| 18 | if (!inDocs || !englishTopics.includes(rest[2] ?? "")) return <>{children}</>; |
| 19 | return ( |
| 20 | <div className="locale-fallback" lang="en" dir="ltr"> |
| 21 | {children} |
| 22 | </div> |
| 23 | ); |
| 24 | } |
| 25 |