Skip to content

Commit

Permalink
Radhey Radhey
Browse files Browse the repository at this point in the history
  • Loading branch information
samanyougarg committed Dec 31, 2024
1 parent a51b037 commit 1ae8784
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Inter } from "next/font/google";
import { headers } from "next/headers";

import TopLoader from "components/Headers/TopLoader";
import { paramsToLocale } from "shared/functions";

import { PreloadResources } from "./preload-resources";
import Providers from "./providers";
Expand Down Expand Up @@ -53,11 +54,17 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: { children: ReactNode }) {
const headersList = headers();
const pathname = headersList.get("x-invoke-path") || "";
const htmlLang = headersList.get("x-html-lang") || "en";

// Extract locale from path similar to pages
const pathParts = pathname.split("/").filter(Boolean);
const lastPart = pathParts[pathParts.length - 1];
const htmlLang = lastPart === "hi" ? "hi" : "en";

// Log for debugging
console.log("[RootLayout] Path:", pathname);
console.log("[RootLayout] HTML Lang from header:", htmlLang);
console.log("[RootLayout] Path parts:", pathParts);
console.log("[RootLayout] Last part:", lastPart);
console.log("[RootLayout] Using HTML lang:", htmlLang);

return (
<html lang={htmlLang} className={inter.className} suppressHydrationWarning>
Expand Down
3 changes: 2 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export function middleware(req: NextRequest) {

// More robust locale detection
const pathParts = pathname.split("/").filter(Boolean);
const hasHindiInPath = pathname.includes("/hi") || pathname === "/hi" || pathname.endsWith("/hi");
const hasHindiInPath =
pathname.includes("/hi") || pathname === "/hi" || pathname.endsWith("/hi");
const isHindiCookie = cookieL === "hi";
const locale = hasHindiInPath || isHindiCookie ? "hi" : "en";

Expand Down

0 comments on commit 1ae8784

Please sign in to comment.