Fix regional locale detection

This commit is contained in:
Shubham Singh
2026-07-30 14:29:25 +05:30
parent 146c287aba
commit cb3f0b49a8
3 changed files with 124 additions and 6 deletions
+2 -6
View File
@@ -2,6 +2,7 @@
import { cookies, headers } from "next/headers";
import { Locale, defaultLocale, locales } from "@/i18n/config";
import { detectLocale } from "@/i18n/detectLocale";
import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
@@ -47,12 +48,7 @@ export async function getUserLocale(): Promise<Locale> {
const acceptLang = headerList.get("accept-language");
if (acceptLang) {
const browserLang = acceptLang.split(",")[0];
const matched = locales.find((locale) =>
browserLang
.toLowerCase()
.startsWith(locale.split("-")[0].toLowerCase())
);
const matched = detectLocale(acceptLang);
if (matched) {
return matched;
}