feat: some locale links

This commit is contained in:
tresabhi committed 2024-12-27 13:43:25 -06:00
1 parent eb5527706e
commit 8203db3dc2
4 files changed
+47 -12

No files matched your search

@@ -38,17 +38,16 @@ const isRoot = pathname === '/';
<Party3 />
<script>
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/core';
import { SUPPORTED_LOCALES } from '@blitzkit/core';
import { getBestLocale } from '../core/i18n/getBestLocale';
const isI18nPath = SUPPORTED_LOCALES.some((locale) =>
window.location.pathname.startsWith(`/${locale}`),
);
const desiredLocale = navigator.language.split('-')[0];
const isSupported = SUPPORTED_LOCALES.includes(desiredLocale);
const isDefault = desiredLocale === DEFAULT_LOCALE;
const bestLocale = getBestLocale();
if (!isI18nPath && isSupported && !isDefault) {
window.location.pathname = `/${desiredLocale}${window.location.pathname}`;
if (!isI18nPath && bestLocale !== undefined) {
window.location.pathname = `/${bestLocale}${window.location.pathname}`;
}
</script>
</head>