mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: some locale links
This commit is contained in:
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>
|
||||
|
||||
Reference in new issue
Block a user