mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Remove locale redirection logic
Removed locale redirection logic from LocaleRedirector component.
This commit is contained in:
1 parent
c24a2989fa
commit
115fa5acad
1 file changed
-24
@@ -1,27 +1,3 @@
|
|||||||
<script>
|
<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>
|
</script>
|
||||||
Reference in new issue
Block a user