Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Nov 29, 2024
1 parent 3c0872b commit 5df19d5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ const locales = Object.keys(data.site.value.locales) as string[];
const localesRegex = new RegExp(`^/(${locales.join('|')})`);
const savedLocale = localStorage.getItem('ais:locale');
if (inBrowser && !localesRegex.test(route.path)) {
if (savedLocale != null && locales.includes(savedLocale)) {
location.replace('/' + savedLocale + location.pathname + location.search);
} else if (locales.includes(navigator.language.split('-')[0])) {
location.replace('/' + navigator.language.split('-')[0] + location.pathname + location.search);
if (inBrowser) {
if (!localesRegex.test(route.path)) {
if (savedLocale != null && locales.includes(savedLocale)) {
location.replace('/' + savedLocale + location.pathname + location.search);
} else if (locales.includes(navigator.language.split('-')[0])) {
location.replace('/' + navigator.language.split('-')[0] + location.pathname + location.search);
} else {
location.replace('/ja' + location.pathname + location.search);
}
} else {
location.replace('/ja' + location.pathname + location.search);
loaded.value = true;
}
}
if (inBrowser) {
loaded.value = true;
}
watch(data.lang, (lang) => {
if (inBrowser) {
localStorage.setItem('ais:locale', lang.split('-')[0]);
Expand Down

0 comments on commit 5df19d5

Please sign in to comment.