improve handling of vuetify locale

This commit is contained in:
vabene1111
2025-11-11 15:40:50 +01:00
parent a05f1ece24
commit 49e0b5b962
2 changed files with 23 additions and 12 deletions

View File

@@ -131,7 +131,7 @@
<script lang="ts" setup>
import GlobalSearchDialog from "@/components/inputs/GlobalSearchDialog.vue"
import {useDisplay} from "vuetify"
import {useDisplay, useLocale} from "vuetify"
import VSnackbarQueued from "@/components/display/VSnackbarQueued.vue";
import MessageListDialog from "@/components/dialogs/MessageListDialog.vue";
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
@@ -152,6 +152,7 @@ const {t} = useI18n()
const title = useTitle()
const router = useRouter()
const i18n = useI18n()
const isPrintMode = useMediaQuery('print')
@@ -161,13 +162,20 @@ onMounted(() => {
router.push({name: 'WelcomePage'})
}
})
const {current} = useLocale()
let locale = document.querySelector('html')!.getAttribute('lang')
if (locale != null) {
current.value = locale
}
})
/**
* global title update handler, might be overridden by page specific handlers
*/
router.afterEach((to, from) => {
if(to.name == 'StartPage' && useUserPreferenceStore().initCompleted && !useUserPreferenceStore().activeSpace.spaceSetupCompleted != undefined &&!useUserPreferenceStore().activeSpace.spaceSetupCompleted && useUserPreferenceStore().activeSpace.createdBy.id! == useUserPreferenceStore().userSettings.user.id!){
if (to.name == 'StartPage' && useUserPreferenceStore().initCompleted && !useUserPreferenceStore().activeSpace.spaceSetupCompleted != undefined && !useUserPreferenceStore().activeSpace.spaceSetupCompleted && useUserPreferenceStore().activeSpace.createdBy.id! == useUserPreferenceStore().userSettings.user.id!) {
router.push({name: 'WelcomePage'})
}
nextTick(() => {

View File

@@ -5,6 +5,7 @@ import {aliases, fa} from 'vuetify/iconsets/fa'
// Composables
import {createVuetify} from 'vuetify'
import {DateTime} from "luxon";
import {af, ar, az, bg, ca, ckb, cs, da, de, el, en, es, et, fi, fr, he, hr, hu, id, it, ja, km, ko, lt, lv, nl, no, pl, pt, ro, ru, sk, sl, srCyrl, srLatn, sv, th, tr, uk, vi, zhHans, zhHant} from "vuetify/locale";
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({
@@ -22,22 +23,24 @@ export default createVuetify({
maxWidth: '1400px'
},
// always localize the date display of DateInputs
VDateInput: {
displayFormat: (date: Date) => DateTime.fromJSDate(date).toLocaleString()
},
// VDateInput: {
// displayFormat: (date: Date) => DateTime.fromJSDate(date).toLocaleString()
// },
// always use color for switches to properly see if enabled or not
VSwitch: {
color: 'primary'
},
// globally set the correct decimal seperator
VNumberInput: {
decimalSeparator: 0.1.toLocaleString().replace(/\d/g, '')
}
// VNumberInput: {
// decimalSeparator: 0.1.toLocaleString().replace(/\d/g, '')
// }
},
locale: {
locale: 'en',
fallback: 'en',
messages: {af, ar, az, bg, ca, ckb, cs, da, de, el, en, es, et, fi, fr, he, hr, hu, id, it, ja, km, ko, lt, lv, nl, no, pl, pt, ro, ru, sk, sl, srCyrl, srLatn, sv, th, tr, uk, vi, zhHans, zhHant},
decimalSeparator: 0.1.toLocaleString().replace(/\d/g, '')
},
// locale: {
// locale: 'de',
// fallback: 'en',
// },
theme: {
defaultTheme: 'light',
themes: {