fix language switching close #51

This commit is contained in:
Adrian Zürcher
2026-02-13 20:16:17 +01:00
parent 9b2b1d3ef7
commit ce654bbb6a
6 changed files with 134 additions and 17 deletions

View File

@@ -31,16 +31,16 @@
</q-tabs>
</div>
<div class="row">
<q-date v-model="dateRange" range flat />
<q-date :locale="calendarLanguage" v-model="dateRange" range flat />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, watch, type PropType } from 'vue';
import { ref, onMounted, watch, type PropType, computed } from 'vue';
import { date } from 'quasar';
import { i18n } from 'src/boot/lang';
import type { QDateLocale } from 'src/vueLib/models/qDateLocale';
const props = defineProps({
title: String,
height: { type: Number, default: 400 },
@@ -74,6 +74,20 @@ const weekdayOptions = [
{ label: i18n.global.t('SundayShort'), value: 0 },
];
const calendarLanguage = computed(() => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const localeData = i18n.global.tm('calendar') as unknown as QDateLocale;
return {
days: localeData.days,
daysShort: localeData.daysShort,
months: localeData.months,
monthsShort: localeData.monthsShort,
firstDayOfWeek: localeData.firstDayOfWeek,
format24h: localeData.format24h,
pluralDay: localeData.pluralDay,
};
});
const onTabChange = (val: 'today' | 'week' | 'month' | 'year') => {
if (val) setRange(val);
// Optional: Reset tab to empty so user can click the same tab again later