Remove locale redirection logic

Removed locale redirection logic from LocaleRedirector component.
This commit is contained in:
TrèsAbhi authored and GitHub committed 2026-02-12 07:14:11 -06:00
1 parent c24a2989fa
commit 115fa5acad
1 file changed
-24
@@ -1,27 +1,3 @@
<script>
import locales from "@blitzkit/i18n/locales.json";
import { getBestLocale } from "../core/i18n/getBestLocale";
const isAPI = window.location.pathname.startsWith("/api");
const isI18nPath = locales.supported.some(({ locale }) =>
window.location.pathname.startsWith(`/${locale}/`),
);
const bestLocale = getBestLocale();
const currentPath = locales.supported.find(({ locale }) =>
window.location.pathname.startsWith(`/${locale}/`),
);
if (
!isAPI && // not an api, duh!
localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler
((bestLocale === locales.default && currentPath !== undefined) ||
(bestLocale !== currentPath))
) {
window.location.pathname = isI18nPath
? window.location.pathname.replace(
`/${currentPath?.locale}`,
bestLocale === locales.default ? "" : `/${bestLocale}`,
)
: `${bestLocale}${window.location.pathname}`;
}
</script>