This commit is contained in:
Shiny Nematoda 2023-07-23 15:07:28 +00:00
parent be45a401b7
commit 27126b64be
6 changed files with 169 additions and 181 deletions

View file

@ -112,7 +112,8 @@ onBeforeMount(() => {
if (store.prm == 'true') document.body.classList.add('prm');
/* Set the default locale if set */
if (store.locale) setupLocale(store.locale);
const loc = store.locale || (navigator.language.startsWith('en') ? null : navigator.language)
if (loc) setupLocale(loc);
/* Set the default tab */
if (location.pathname == '/' && store.page) nav.state.page = store.page;

View file

@ -1,3 +1,3 @@
{
"date": "2023-07-16"
"date": "2023-07-23"
}

View file

@ -1,5 +1,5 @@
<script setup>
import { onMounted, onUpdated, ref } from 'vue';
import { ref } from 'vue';
import Btn from './Btn.vue';
import { useStore } from '@/scripts/util.js';

View file

@ -136,12 +136,13 @@ export const useI18n = defineStore('i18n', () => {
}
function setupLocale(code) {
import(`@/locales/${code}.json`)
.then(mod => mod.default)
.then(mod => {
map.value[code] = mod;
locale.value = code;
});
if (SUPPORTED_LOCALES.some(i => i.code == code))
import(`@/locales/${code}.json`)
.then(mod => mod.default)
.then(mod => {
map.value[code] = mod;
locale.value = code;
});
}
return { locale, map, t, setupLocale };